What a Beautiful Data!

Leetcode 다시풀기 1141 dau

by darami

1141. User Activity for the Past 30 Days I

 

데이터 설명 중 

There is no primary key for this table, it may have duplicate rows. The activity_type column is an ENUM of type ('open_session', 'end_session', 'scroll_down', 'send_message'). The table shows the user activities for a social media website. Note that each session belongs to exactly one user.
 
enum은 열거형(enumerated type)이라고 부른다. 열거형은 서로 연관된 상수들의 집합이라고 할 수 있다. 

https://opentutorials.org/course/2517/14151

SELECT activity_date AS day
,COUNT(DISTINCT user_id) as active_users
FROM Activity
WHERE (activity_date BETWEEN '2019-06-28' AND '2019-07-27')
AND activity_type IS NOT NULL
GROUP BY activity_date

매번 풀던 거라 코드는 매우 간단하게 풀었다. 

이게 기분 좋았다.

다른 풀이 

select activity_date as day, count(distinct user_id) as active_users
from Activity
where datediff('2019-07-27', activity_date) <30
group by activity_date
이풀이도 비슷하지만 datediff..
블로그의 프로필 사진

블로그의 정보

다람

darami

활동하기