Find the first login time of the visited player.
Example :
Table: Activity
+-----------+-----------+------------+--------------+
| player_id | device_id | event_date | games_played |
+-----------+-----------+------------+--------------+
| 1 | 2 | 2020-12-01 | 5 |
| 1 | 2 | 2021-01-02 | 6 |
| 2 | 3 | 2021-01-04 | 1 |
| 3 | 1 | 2020-12-02 | 8 |
| 3 | 4 | 2020-12-25 | 5 |
+-----------+-----------+------------+--------------+
Result
+-----------+-------------+
| player_id | first_login |
+-----------+-------------+
| 1 | 2020-12-01 |
| 2 | 2021-01-04 |
| 3 | 2020-12-25 |
+-----------+-------------+
Approach:
Mysql
SELECT player_id, min(event_date) as first_login
FROM Activity GROUP BY player_id;
Oracle
SELECT player_id, min(event_date) as first_login
FROM Activity GROUP BY player_id;
No comments:
Post a Comment