File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ Have a good contributing!
4848 - [ 620. Not Boring Movies] ( ./leetcode/easy/620.%20Not%20Boring%20Movies.sql )
4949 - [ 1068. Product Sales Analysis I] ( ./leetcode/easy/1068.%20Product%20Sales%20Analysis%20I.sql )
5050 - [ 1407. Top Travellers] ( ./leetcode/easy/1407.%20Top%20Travellers.sql )
51+ - [ 1484. Group Sold Products By The Date] ( ./leetcode/easy/1484.%20Group%20Sold%20Products%20By%20The%20Date.sql )
51522 . [ Medium] ( ./leetcode/medium/ )
5253 - [ 176. Second Highest Salary] ( ./leetcode/medium/176.%20Second%20Highest%20Salary.sql )
5354 - [ 184. Department Highest Salary] ( ./leetcode/medium/184.%20Department%20Highest%20Salary.sql )
Original file line number Diff line number Diff line change 1+ /*
2+ Question 1484. Group Sold Products By The Date
3+ Link: https://leetcode.com/problems/group-sold-products-by-the-date/description/
4+
5+ Table Activities:
6+
7+ +-------------+---------+
8+ | Column Name | Type |
9+ +-------------+---------+
10+ | sell_date | date |
11+ | product | varchar |
12+ +-------------+---------+
13+ There is no primary key (column with unique values) for this table. It may contain duplicates.
14+ Each row of this table contains the product name and the date it was sold in a market.
15+
16+
17+ Write a solution to find for each date the number of different products sold and their names.
18+
19+ The sold products names for each date should be sorted lexicographically.
20+
21+ Return the result table ordered by sell_date.
22+ */
23+
24+ SELECT
25+ sell_date,
26+ COUNT (DISTINCT product) AS num_sold,
27+ STRING_AGG(DISTINCT product, ' ,' ORDER BY product) AS products
28+ FROM Activities
29+ GROUP BY 1
30+ ORDER BY 1
You can’t perform that action at this time.
0 commit comments