31. Every Product and Units Sold
EasyJoinsLEFT JOINCOALESCEGROUP BY
A LEFT JOIN keeps every row from the left table even when the right table has no match — the right-side columns come back as NULL. That's how you include products that have never sold.
Task: list every product with the total quantity sold. Products with no sales must still appear, showing 0. Use COALESCE (or IFNULL) to turn the NULL sum into 0.
Output columns, in this exact order: product, units_sold. Order the rows by product ascending.
Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.
SQL· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.