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-5.sql 496B

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