Changes between Version 3 and Version 4 of SQL
- Timestamp:
- 02/07/25 17:37:05 (2 weeks ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
SQL
v3 v4 6 6 SELECT 7 7 c.company_id, 8 c. name AScompany_name,8 c.company_name, 9 9 SUM(i.total_amount) AS total_revenue 10 10 FROM … … 14 14 i.issue_date BETWEEN NOW() - INTERVAL '1 year' AND NOW() 15 15 GROUP BY 16 c.company_id, c. name16 c.company_id, c.company_name 17 17 ORDER BY 18 18 total_revenue DESC; … … 23 23 SELECT 24 24 cl.client_id, 25 cl. name ASclient_name,25 cl.client_name, 26 26 COUNT(i.invoice_id) AS total_invoices, 27 27 SUM(i.total_amount) AS total_amount … … 30 30 JOIN Invoice i ON cl.client_id = i.client_id 31 31 GROUP BY 32 cl.client_id, cl. name32 cl.client_id, cl.client_name 33 33 ORDER BY 34 34 total_amount DESC; … … 58 58 SELECT 59 59 cl.client_id, 60 cl. name ASclient_name,60 cl.client_name, 61 61 SUM(i.total_amount) AS total_paid 62 62 FROM … … 66 66 i.status = 'Paid' 67 67 GROUP BY 68 cl.client_id, cl. name68 cl.client_id, cl.client_name 69 69 ORDER BY 70 70 total_paid DESC … … 76 76 SELECT 77 77 cl.client_id, 78 cl. name ASclient_name,78 cl.client_name, 79 79 COUNT(i.invoice_id) AS outstanding_invoices, 80 80 SUM(i.total_amount) AS outstanding_amount … … 85 85 i.status = 'Unpaid' 86 86 GROUP BY 87 cl.client_id, cl. name87 cl.client_id, cl.client_name 88 88 ORDER BY 89 89 outstanding_amount DESC;