[LeetCode] 511. Game Play Analysis I

2022. 11. 27. 15:47TIL💡/Database

https://leetcode.com/problems/game-play-analysis-i/

 

Game Play Analysis I - LeetCode

Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.

leetcode.com

GROUP BY를 활용하면 간단한 문제인데, 셀프조인으로 빙빙 돌려서 조건문 처리할 생각을 하던 나 자신.. 반성해..!

 

Intuition

Group rows into subgroups specific to each player with GROUP BY and then extract the minimum date value from each group with MIN()

SELECT player_id, MIN(event_date) AS first_login
FROM Activity
GROUP BY player_id;