Leetcode 다시풀기 1141 dau
by darami1141. 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..
'SQL > Leetcode' 카테고리의 다른 글
리트코드 1050,1158 풀이 + 이틀간 피시방에서 코딩 한 소감 + 장단점 (0) | 2022.07.19 |
---|---|
리트코드 다시 풀기 1393,1667+ 성능고민 (0) | 2022.07.03 |
Leetcode 다시풀기 607,627,1084 (0) | 2022.06.24 |
Leetcode 다시 풀기 584, 586 mysql 문제 풀이 (0) | 2022.06.24 |
Leetcode 다시풀기 (hard) 185 , (easy) 196,197 (0) | 2022.06.23 |
블로그의 정보
다람
darami