1. Description
Table: Activity
+--------------+---------+
| Column Name | Type |
+--------------+---------+
| player_id | int |
| device_id | int |
| event_date | date |
| games_played | int |
+--------------+---------+
(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.
Write an SQL query to report the first login date for each player.
Return the result table in any order.
The query result format is in the following example.
2. Algorithms
We need to extract the first event_date while we do grouping table by player_id.
3. Codes
# Write your MySQL query statement below
SELECT player_id, min(event_date) as first_login
FROM activity
GROUP BY player_id;
4. Conclusion
'LeetCode > Easy' 카테고리의 다른 글
521 Longest Uncommon Subsequence I (0) | 2022.09.04 |
---|---|
520 Detect Capital (0) | 2022.09.03 |
509 Fibonacci Number (0) | 2022.09.03 |
507 Perfect Number (0) | 2022.09.03 |
506 Relative Ranks (0) | 2022.09.03 |