1- -- 511. Game Play Analysis I
2- --
3- -- Table: Activity
4- --
5- -- +--------------+---------+
6- -- | Column Name | Type |
7- -- +--------------+---------+
8- -- | player_id | int |
9- -- | device_id | int |
10- -- | event_date | date |
11- -- | games_played | int |
12- -- +--------------+---------+
13- -- (player_id, event_date) is the primary key of this table.
14- -- This table shows the activity of players of some game.
15- -- Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on some day using some device.
16- --
17- --
18- -- Write an SQL query that reports the first login date for each player.
19- --
20- -- The query result format is in the following example:
21- --
22- -- Activity table:
23- -- +-----------+-----------+------------+--------------+
24- -- | player_id | device_id | event_date | games_played |
25- -- +-----------+-----------+------------+--------------+
26- -- | 1 | 2 | 2016-03-01 | 5 |
27- -- | 1 | 2 | 2016-05-02 | 6 |
28- -- | 2 | 3 | 2017-06-25 | 1 |
29- -- | 3 | 1 | 2016-03-02 | 0 |
30- -- | 3 | 4 | 2018-07-03 | 5 |
31- -- +-----------+-----------+------------+--------------+
32- --
33- -- Result table:
34- -- +-----------+-------------+
35- -- | player_id | first_login |
36- -- +-----------+-------------+
37- -- | 1 | 2016-03-01 |
38- -- | 2 | 2017-06-25 |
39- -- | 3 | 2016-03-02 |
40- -- +-----------+-------------+
41-
42- -- # Write your MySQL query statement below
43-
441select player_id, min (event_date) as first_login
452from Activity
463group by player_id
0 commit comments