You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

demo-queries-from slides-2.sql 834B

12345678910111213141516171819202122232425
  1. SELECT 'After 1/1/2018' AS selection_date,
  2. COUNT(*) AS number_of_invoices,
  3. ROUND(AVG(invoice_total), 2) AS avg_invoice_amt,
  4. SUM(invoice_total) AS total_invoice_amt
  5. FROM invoices
  6. WHERE invoice_date > '2018-01-01';
  7. SELECT 'After 1/1/2018' AS selection_date,
  8. COUNT(*) AS number_of_invoices,
  9. MAX(invoice_total) AS highest_invoice_total,
  10. MIN(invoice_total) AS lowest_invoice_total
  11. FROM invoices
  12. WHERE invoice_date > '2018-01-01';
  13. SELECT MIN(vendor_name) AS first_vendor,
  14. MAX(vendor_name) AS last_vendor,
  15. COUNT(vendor_name) AS number_of_vendors
  16. FROM vendors;
  17. SELECT COUNT(DISTINCT vendor_id) AS number_of_vendors,
  18. COUNT(vendor_id) AS number_of_invoices,
  19. ROUND(AVG(invoice_total), 2) AS avg_invoice_amt,
  20. SUM(invoice_total) AS total_invoice_amt
  21. FROM invoices
  22. WHERE invoice_date > '2018-01-01';