123456789101112131415161718 |
- SELECT vendor_id, COUNT(*) AS invoice_qty
- FROM invoices
- GROUP BY vendor_id;
-
- SELECT vendor_state, vendor_city, COUNT(*) AS invoice_qty,
- ROUND(AVG(invoice_total), 2) AS invoice_avg
- FROM invoices JOIN vendors
- ON invoices.vendor_id = vendors.vendor_id
- GROUP BY vendor_state, vendor_city
- ORDER BY vendor_state, vendor_city;
-
- SELECT vendor_state, vendor_city, COUNT(*) AS invoice_qty,
- ROUND(AVG(invoice_total), 2) AS invoice_avg
- FROM invoices JOIN vendors
- ON invoices.vendor_id = vendors.vendor_id
- GROUP BY vendor_state, vendor_city
- HAVING COUNT(*) >= 2
- ORDER BY vendor_state, vendor_city;
|