[LeetCode-SQL 50] 1484. Group Sold Products By The Date

코린이·2025년 6월 29일

SQL 문제 풀이 (MySQL)

목록 보기
94/96

❓ 문제

Activities:
+-------------+---------+
| Column Name | Type    |
+-------------+---------+
| sell_date   | date    |
| product     | varchar |
+-------------+---------+

이 테이블에 대한 기본 키(고유 값을 가진 열)가 없습니다. 중복이 있을 수 있습니다.
이 테이블의 각 행에는 제품 이름과 마켓에서 판매된 날짜가 포함되어 있습니다.

각 날짜별로 판매된 다른 제품의 수와 이름을 찾는 솔루션을 작성합니다.

각 날짜의 판매된 제품 이름은 사전 순으로 정렬해야 합니다.

sell_date 순으로 정렬된 결과 테이블을 반환합니다.

자세한 문제 내용은 사이트 참고...


❗️ 문제 풀이

select
    sell_date
    , count(distinct product) as num_sold
    , group_concat(distinct product order by product) as products
from Activities
group by sell_date
order by sell_date
;

🔗 Reference

https://leetcode.com/problems/group-sold-products-by-the-date/description/?envType=study-plan-v2&envId=top-sql-50

0개의 댓글