Changes between Version 3 and Version 4 of SQL


Ignore:
Timestamp:
02/07/25 17:37:05 (2 weeks ago)
Author:
163080
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SQL

    v3 v4  
    66SELECT
    77    c.company_id,
    8     c.name AS company_name,
     8    c.company_name,
    99    SUM(i.total_amount) AS total_revenue
    1010FROM
     
    1414    i.issue_date BETWEEN NOW() - INTERVAL '1 year' AND NOW()
    1515GROUP BY
    16     c.company_id, c.name
     16    c.company_id, c.company_name
    1717ORDER BY
    1818    total_revenue DESC;
     
    2323SELECT
    2424    cl.client_id,
    25     cl.name AS client_name,
     25    cl.client_name,
    2626    COUNT(i.invoice_id) AS total_invoices,
    2727    SUM(i.total_amount) AS total_amount
     
    3030JOIN Invoice i ON cl.client_id = i.client_id
    3131GROUP BY
    32     cl.client_id, cl.name
     32    cl.client_id, cl.client_name
    3333ORDER BY
    3434    total_amount DESC;
     
    5858SELECT
    5959    cl.client_id,
    60     cl.name AS client_name,
     60    cl.client_name,
    6161    SUM(i.total_amount) AS total_paid
    6262FROM
     
    6666    i.status = 'Paid'
    6767GROUP BY
    68     cl.client_id, cl.name
     68    cl.client_id, cl.client_name
    6969ORDER BY
    7070    total_paid DESC
     
    7676SELECT
    7777    cl.client_id,
    78     cl.name AS client_name,
     78    cl.client_name,
    7979    COUNT(i.invoice_id) AS outstanding_invoices,
    8080    SUM(i.total_amount) AS outstanding_amount
     
    8585    i.status = 'Unpaid'
    8686GROUP BY
    87     cl.client_id, cl.name
     87    cl.client_id, cl.client_name
    8888ORDER BY
    8989    outstanding_amount DESC;