From 1d942a5d7ef5ff80ddb963cf6e853311096172bd Mon Sep 17 00:00:00 2001 From: Antim Pal <134076504+iamAntimPal@users.noreply.github.com> Date: Sun, 23 Mar 2025 22:49:22 +0530 Subject: [PATCH 1/3] Create 1484. Group Sold Products By The Date.SQL --- .../1484. Group Sold Products By The Date.SQL | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL diff --git a/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL b/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL new file mode 100644 index 0000000..e69de29 From 30cd2140526112de087159c1d0a038054312ee3c Mon Sep 17 00:00:00 2001 From: Antim Pal <134076504+iamAntimPal@users.noreply.github.com> Date: Sun, 23 Mar 2025 22:49:30 +0530 Subject: [PATCH 2/3] Update 1484. Group Sold Products By The Date.SQL --- .../1484. Group Sold Products By The Date.SQL | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL b/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL index e69de29..ccf0ab1 100644 --- a/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL +++ b/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL @@ -0,0 +1,56 @@ +1484. Group Sold Products By The Date +Solved +Easy +Topics +Companies +SQL Schema +Pandas Schema +Table Activities: + ++-------------+---------+ +| Column Name | Type | ++-------------+---------+ +| sell_date | date | +| product | varchar | ++-------------+---------+ +There is no primary key (column with unique values) for this table. It may contain duplicates. +Each row of this table contains the product name and the date it was sold in a market. + + +Write a solution to find for each date the number of different products sold and their names. + +The sold products names for each date should be sorted lexicographically. + +Return the result table ordered by sell_date. + +The result format is in the following example. + + + +Example 1: + +Input: +Activities table: ++------------+------------+ +| sell_date | product | ++------------+------------+ +| 2020-05-30 | Headphone | +| 2020-06-01 | Pencil | +| 2020-06-02 | Mask | +| 2020-05-30 | Basketball | +| 2020-06-01 | Bible | +| 2020-06-02 | Mask | +| 2020-05-30 | T-Shirt | ++------------+------------+ +Output: ++------------+----------+------------------------------+ +| sell_date | num_sold | products | ++------------+----------+------------------------------+ +| 2020-05-30 | 3 | Basketball,Headphone,T-shirt | +| 2020-06-01 | 2 | Bible,Pencil | +| 2020-06-02 | 1 | Mask | ++------------+----------+------------------------------+ +Explanation: +For 2020-05-30, Sold items were (Headphone, Basketball, T-shirt), we sort them lexicographically and separate them by a comma. +For 2020-06-01, Sold items were (Pencil, Bible), we sort them lexicographically and separate them by a comma. +For 2020-06-02, the Sold item is (Mask), we just return it. \ No newline at end of file From 93720734f89c8c71c3c2ea754cdea2a7e0877038 Mon Sep 17 00:00:00 2001 From: Antim Pal <134076504+iamAntimPal@users.noreply.github.com> Date: Sun, 23 Mar 2025 22:49:52 +0530 Subject: [PATCH 3/3] Update 1484. Group Sold Products By The Date.SQL --- .../1484. Group Sold Products By The Date.SQL | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL b/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL index ccf0ab1..b89bee9 100644 --- a/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL +++ b/LeetCode SQL 50 Solution/1484. Group Sold Products By The Date.SQL @@ -53,4 +53,12 @@ Output: Explanation: For 2020-05-30, Sold items were (Headphone, Basketball, T-shirt), we sort them lexicographically and separate them by a comma. For 2020-06-01, Sold items were (Pencil, Bible), we sort them lexicographically and separate them by a comma. -For 2020-06-02, the Sold item is (Mask), we just return it. \ No newline at end of file +For 2020-06-02, the Sold item is (Mask), we just return it. + + + +select sell_date, count( DISTINCT product ) as num_sold , + + GROUP_CONCAT( DISTINCT product order by product ASC separator ',' ) as products + + FROM Activities GROUP BY sell_date order by sell_date ASC; \ No newline at end of file