CREATE OR REPLACE VIEW invoice_summary AS
SELECT vendor_name,
COUNT(*) AS invoice_count,
SUM(invoice_total) AS invoice_total_sum
FROM vendors JOIN invoices
ON vendors.vendor_id = invoices.vendor_id
GROUP BY vendor_name
Remember a while back we talked about getting aggregate data out of our database, one way we can do this is to create views to generate the aggregate reports