[코드카타] SQL 62 Group Sold Products By The Date

Data_Student·2024년 12월 11일
0

코드카타

목록 보기
72/82

[코드카타] SQL 62 Group Sold Products By The Date

62 Group Sold Products By The Date
https://leetcode.com/problems/group-sold-products-by-the-date/

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) num_sold, 
        group_concat(distinct product order by product separator ',') products
From Activities 
group by sell_date
order by sell_date
★group_concat() 활용 - 그룹화한 컬럼의 값들을 합쳐서 나타내기
distinct를 사용한 이유 - 중복된 물건에 대해서 하나만 카운드 or 추출하기 위함

0개의 댓글