문제 99번. [Number of Unique Subjects Taught by Each Teacher]
(https://leetcode.com/problems/number-of-unique-subjects-taught-by-each-teacher/)
select teacher_id, count(distinct subject_id) as cnt
from teacher
group by teacher_id
문제 100번. [User Activity for the Past 30 Days I]
(https://leetcode.com/problems/user-activity-for-the-past-30-days-i/description/)
select
activity_date as day,
count(distinct user_id) as active_users
from activity
where activity_date >= '2019-06-28' and activity_date < '2019-07-28'
group by activity_date
문제 101번. [Product Sales Analysis III]
(https://leetcode.com/problems/product-sales-analysis-iii/description/)
select product_id, year as first_year, quantity, price
from sales
where (product_id, year) in (
select product_id, min(year)
from sales
group by product_id)
이 문제는 약간 함정이 있었는데, 테이블은 두 개가 주어지지만 join을 하지 않아도 풀 수 있는 문제였다.