[SQL문제풀기] 가구 판매의 비중이 높았던 날 찾기

silver's avatar
Mar 19, 2025
[SQL문제풀기] 가구 판매의 비중이 높았던 날 찾기
Contents
문제SQLite

문제

SQLite

내가 작성한 오답

: 중복된 id가 존재해서 distinct로 걸러줘야 했다.
notion image
notion image
notion image
notion image
with a as (select order_date, count(order_id) cnt from records where category = 'Furniture' group by order_date) select a.order_date, a.cnt furniture, round((a.cnt*100.00/count(r.order_id)),2) furniture_pct from records r left join a a on r.order_date = a.order_date group by a.order_date having count(order_id) >=10 and furniture_pct >= 40 order by 3 desc, 1

내가 작성한 정답

with a as (select order_date, count(distinct order_id) cnt from records where category = 'Furniture' group by order_date) select a.order_date, a.cnt furniture, round((a.cnt*100.00/count(distinct r.order_id)),2) furniture_pct from records r left join a a on r.order_date = a.order_date group by a.order_date having count(distinct order_id) >=10 and furniture_pct >= 40 order by 3 desc, 1
Share article

silver