topic
Column Name | Type |
---|---|
player_id | int |
device_id | int |
event_date | date |
games_played | int |
The primary key of the table is (player_id, event_date).
This table shows the behavioral activities of some game players on the gaming platform.
Each row of data records the number of games a player opened after logging in to the platform using the same device that day before exiting the platform (possibly 0).
Write a SQL query to obtain the date each player first logged into the platform.
The format of the query results is as follows:
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 |
Result table:
player_id | first_login |
---|---|
1 | 2016-03-01 |
2 | 2017-06-25 |
3 | 2016-03-02 |
Knowledge points
AS: Set the header of query results
Code that runs successfully
SELECT DISTINCT PLAYER_ID,MIN(EVENT_DATE) AS FIRST_LOGIN
FROM ACTIVITY
GROUP BY PLAYER_ID