This repository has been archived on 2026-10-10. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
chinook/line_items_per_invoice.sql
T

10 lines
258 B
SQL

/* My theory */
SELECT COUNT(InvoiceLineId)
FROM InvoiceLine
GROUP BY InvoiceLine.InvoiceId;
/* Correct Answer */
select i.InvoiceId, count(il.invoiceId) line_item_count
from Invoice i
join InvoiceLine il on i.InvoiceId = il.InvoiceId
group by il.InvoiceId;