SQL problem - Fix Names in a Table
Problem
Query
SELECT
sell_date,
COUNT(DISTINCT product) as num_sold,
GROUP_CONCAT(DISTINCT product) as products
FROM
Activities
GROUP BY
sell_date
ORDER BY sell_date
Editorial Solution
Approach: Grouping and aggregation of strings
SELECT
sell_date,
COUNT(DISTINCT(product)) AS num_sold,
GROUP_CONCAT(DISTINCT product ORDER BY product SEPARATOR ',') AS products
FROM
Activities
GROUP BY
sell_date
ORDER BY
sell_date ASC