LeetCode 511. Game Play Analysis I SQL Solution
Problem
LeetCode SQL Problem
- Game Play Analysis I
Activity table
player_id | device_id | event_date | games_played |
---|---|---|---|
1 | 2 | 2016-03-01 | 5 |
1 | 2 | 2016-05-02 | 6 |
2 | 3 | 2017-06-25 | 1 |
3 | 1 | 2016-03-02 | 0 |
3 | 4 | 2018-07-03 | 5 |
Solution
- MySQL
- TSQL
Report the first login date for each player
SELECT player_id
,min(event_date) AS first_login
FROM Activity
GROUP BY player_id
Report the first login date for each player
SELECT player_id
,min(event_date) AS first_login
FROM Activity
GROUP BY player_id
Query Output
player_id | first_login |
---|---|
1 | 2016-03-01 |
2 | 2017-06-25 |
3 | 2016-03-02 |