[코드카타] SQL 39 User Activity for the Past 30 Days I

Data_Student·6일 전
0

코드카타

목록 보기
48/57

[코드카타] SQL 39 User Activity for the Past 30 Days I

39. User Activity for the Past 30 Days I
https://leetcode.com/problems/user-activity-for-the-past-30-days-i/description/

Write a solution to find the daily active user count for 
a period of 30 days ending 2019-07-27 inclusively. 
A user was active on someday if they made at least one activity 
on that day.
Return the result table in any order.
Select activity_date day, count(distinct user_id) active_users
From Activity
where activity_date between (date_sub('2019-07-27',interval 29 day)) and '2019-07-27'
group by activity_date
date_sub(기준 날짜, interval 00 기준) 활용 
- 날짜 빼기
date-add(기준 날짜, interval 00 기준)
- 날짜 더하기
기준 - 초, 분, 시, 일, 주, 월, 년 으로 나누어서 활용 가능

0개의 댓글