LeetCode 1484. Group Sold Products By The Date
考点 | 难度 |
---|---|
Database | Easy |
题目
Write an SQL query 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,
group_concat(distinct product order by product asc) as products
from activities
group by sell_date
order by sell_date asc