Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Have a good contributing!
- [620. Not Boring Movies](./leetcode/easy/620.%20Not%20Boring%20Movies.sql)
- [1068. Product Sales Analysis I](./leetcode/easy/1068.%20Product%20Sales%20Analysis%20I.sql)
- [1407. Top Travellers](./leetcode/easy/1407.%20Top%20Travellers.sql)
- [1484. Group Sold Products By The Date](./leetcode/easy/1484.%20Group%20Sold%20Products%20By%20The%20Date.sql)
2. [Medium](./leetcode/medium/)
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
- [184. Department Highest Salary](./leetcode/medium/184.%20Department%20Highest%20Salary.sql)
Expand Down
30 changes: 30 additions & 0 deletions leetcode/easy/1484. Group Sold Products By The Date.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Question 1484. Group Sold Products By The Date
Link: https://leetcode.com/problems/group-sold-products-by-the-date/description/

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.
*/

SELECT
sell_date,
COUNT(DISTINCT product) AS num_sold,
STRING_AGG(DISTINCT product, ',' ORDER BY product) AS products
FROM Activities
GROUP BY 1
ORDER BY 1