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-12.sql 469B

123456789101112131415
  1. SELECT vendor_state, vendor_name, SUM(invoice_total) AS sum_of_invoices
  2. FROM vendors v JOIN invoices i
  3. ON v.vendor_id = i.vendor_id
  4. GROUP BY vendor_state, vendor_name;
  5. SELECT vendor_state, MAX(sum_of_invoices) AS sum_of_invoices
  6. FROM
  7. (
  8. SELECT vendor_state, vendor_name,
  9. SUM(invoice_total) AS sum_of_invoices
  10. FROM vendors v JOIN invoices i
  11. ON v.vendor_id = i.vendor_id
  12. GROUP BY vendor_state, vendor_name
  13. ) t
  14. GROUP BY vendor_state;