SQL 문제풀이

leetcode - 511. Game Play Analysis I

Jerrytwo 2022. 6. 30. 17:04

난이도 : Easy

 

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.

 

 

SELECT player_id
     , MIN(event_date) first_login
FROM Activity
GROUP BY player_id

Accepted