Report Each Player’s Earliest Recorded Login

Quick Overview

Return the earliest recorded login for every player, including logins on which no games were played.

Report Each Player’s Earliest Recorded Login

Company: Amazon

Role: Software Engineer

Category: Data Manipulation (SQL/Python)

Difficulty: easy

Interview Round: Other

### Problem Report player_id and first_login, the earliest event_date for each player present in Activity. A logged-in day still counts when games_played is zero. Return the rows in any order. ### Tables Table: `Activity` ```text +--------------+---------+ | Column Name | Type | +--------------+---------+ | player_id | int | | device_id | int | | event_date | date | | games_played | int | +--------------+---------+ (player_id, event_date) is the primary key (combination of columns with unique values) 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. ``` ### Example ```text Activity (player_id,device_id,event_date,games_played): (3,8,2021-05-04,0), (3,9,2021-05-02,2), (7,8,2021-06-01,1) Output (player_id,first_login): (3,2021-05-02), (7,2021-06-01) ``` ### What a Strong Answer Covers - Return one earliest login date for each player. - Include recorded logins even when no games were played. ### Follow-up Questions - How would you return the device used on the first login date? - How would you report the first login in each calendar year?

Overview: Return the earliest recorded login for every player, including logins on which no games were played.

Amazon logo
Amazon
easySoftware EngineerOtherData Manipulation (SQL/Python)
0
0

Problem

Report player_id and first_login, the earliest event_date for each player present in Activity. A logged-in day still counts when games_played is zero. Return the rows in any order.

Tables

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 (combination of columns with unique values) 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.

Example

Activity (player_id,device_id,event_date,games_played): (3,8,2021-05-04,0), (3,9,2021-05-02,2), (7,8,2021-06-01,1)
Output (player_id,first_login): (3,2021-05-02), (7,2021-06-01)

What a Strong Answer Covers Guidance

  • Return one earliest login date for each player.
  • Include recorded logins even when no games were played.

Follow-up Questions Guidance

  • How would you return the device used on the first login date?
  • How would you report the first login in each calendar year?