Game Play Analysis I
Problem
Table: Activity
+--------------+---------+
| Column Name | Type |
+--------------+---------+
| player_id | int |
| device_id | int |
| event_date | date |
| games_played | int |
+--------------+---------+
In SQL, (player_id, event_date) is the primary key of this table.
This table shows the activity of players of some games.
Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on someday using some device.
Find the first login date for each player.
Return the result table in any order.
Solution
The problem Game Play Analysis I
can be solved using the keyword GROUP BY
along with the function MIN
.
Implementation
# Write your MySQL query statement below
SELECT player_id, MIN(event_date) AS first_login
FROM activity
GROUP BY player_id;