41. Distinct Products Per Store
EasyAggregationCOUNT(DISTINCT)GROUP BY
COUNT(*) counts rows; COUNT(DISTINCT col) counts how many different values appear, ignoring repeats and NULLs.
Task: for each store, return how many distinct products it has sold.
Return columns store, distinct_products. Order by distinct_products descending, then store 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.