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-4.sql 600B

123456789101112131415161718
  1. SELECT vendor_id, COUNT(*) AS invoice_qty
  2. FROM invoices
  3. GROUP BY vendor_id;
  4. SELECT vendor_state, vendor_city, COUNT(*) AS invoice_qty,
  5. ROUND(AVG(invoice_total), 2) AS invoice_avg
  6. FROM invoices JOIN vendors
  7. ON invoices.vendor_id = vendors.vendor_id
  8. GROUP BY vendor_state, vendor_city
  9. ORDER BY vendor_state, vendor_city;
  10. SELECT vendor_state, vendor_city, COUNT(*) AS invoice_qty,
  11. ROUND(AVG(invoice_total), 2) AS invoice_avg
  12. FROM invoices JOIN vendors
  13. ON invoices.vendor_id = vendors.vendor_id
  14. GROUP BY vendor_state, vendor_city
  15. HAVING COUNT(*) >= 2
  16. ORDER BY vendor_state, vendor_city;