100 % || INTUITIVE && WELL - EXPLAINED || EASY SQL QUERY || Using GROUP_CONCAT( ) || Beats 89.11 %..
Intuition\n Describe your first thoughts on how to solve this problem. \nSELECT sell_date, --> show sell_date...\nCOUNT(DISTINCT product) AS num_sold, --> Using
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nSELECT sell_date, --> **show** sell_date...\nCOUNT(DISTINCT product) AS num_sold, --> Using **aggregate** function **COUNT** to count product only once **alias** as num_sold...\nGROUP_CONCAT(DISTINCT product ORDER BY product) --> it helps to making a **list**...\nAS products --> **alias** as products...\nFROM Activities --> **Association** from **Activities** table...\nGROUP BY sell_date --> **Grouping** w.r.t. sell_date...\nORDER BY sell_date, product; --> Ordering w.r.t. sell_date & product.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nUsing Fundamentals of **SQL**...\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nSELECT sell_date, \nCOUNT(DISTINCT product) AS num_sold, \nGROUP_CONCAT(DISTINCT product ORDER BY product) \nAS products \nFROM Activities \nGROUP BY sell_date \nORDER BY sell_date, product;\n```
['Database', 'MySQL']