문제: https://platform.stratascratch.com/coding/10141-apple-product-counts/official-solution?code_type=3
나의풀이:
select language
, count(distinct(case when device in ('macbook pro', 'iphone 5s', 'ipad air') then user_id end)) as n_apple_user
, count(distinct user_id) as n_total_users
from playbook_events e
join playbook_users u using (user_id)
group by language
order by 3 desc;
정답~~예엥 솔루션도 똑같다!
처음에는 틀렸는데 문제는 MacBook-Pro 라고 되어있지만 데이터에서는 macbook pro 이렇게 되어있어서 그런 부분들을 수정해줬더니 맞췄당,, 근데 대문자, - 를 포함했을때도 카운트 값이 있었는데 ?.? 문제가 약간 이상한 것 같기도,,
'SQL > StrataScratch' 카테고리의 다른 글
[MySQL] (Medium) Highest Energy Consumption (0) | 2024.02.29 |
---|---|
[MySQL] (Medium) Spam Posts (1) | 2024.02.17 |
[MySQL] (Medium) Number Of Units Per Nationality (0) | 2024.02.14 |
[MySQL] (Medium) Ranking Most Active Guests (0) | 2024.02.14 |
[MySQL] (Medium) Acceptance Rate By Date (0) | 2024.02.09 |