자료구조 알고리즘/코딩테스트
1484. Group Sold Products By The Date
내공얌냠
2022. 5. 30. 17:21
https://leetcode.com/problems/group-sold-products-by-the-date/
Group Sold Products By The Date - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
select sell_date, count(distinct product) as num_sold, group_concat(distinct product) as products
from Activities
group by sell_date
order by sell_date;
best
select sell_date,
count(distinct(product)) as num_sold,
group_concat(distinct(product)) as products
from activities
group by sell_date
order by sell_date
References
https://fruitdev.tistory.com/16
[MySQL] GROUP_CONCAT 사용하기
필요에 의해 서로 다른 결과를 한줄로 합쳐서 보여줘야 할 경우가 있다. 전체 결과값을 가져와서 java 와 같은 프로그램 언어에서 for 문을 돌며 문자열을 붙여도 되긴 하지만 Select 쿼리를 던질때
fruitdev.tistory.com
728x90
반응형