Game Play Analysis I is a very important question that is being asked in many company interviews.
Before getting started first we have to understand the question properly. for that, we need SQL Schema and questions to find the required output.
Let's start with the SQL Schema of the table named Activity:
CREATE TABLE Activity (player_id int, device_id int, event_date date, games_played int)
INSERT INTO Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5')
INSERT INTO Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-05-02', '6')
INSERT INTO Activity (player_id, device_id, event_date, games_played) values ('2', '3', '2017-06-25', '1')
INSERT INTO Activity (player_id, device_id, event_date, games_played) values ('3', '1', '2016-03-02', '0')
INSERT INTO Activity (player_id, device_id, event_date, games_played) values ('3', '4', '2018-07-03', '5')
The Activity table will look like this:
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 |
player_id | first_login |
---|---|
1 | 2016-03-01 |
2 | 2017-06-25 |
3 | 2016-03-02 |
SELECT player_id, MIN(event_date) as first_login FROM Activity GROUP BY player_id;
0 Comments