Similar Problems

Similar Problems not available

Game Play Analysis I - Leetcode Solution

Companies:

LeetCode:  Game Play Analysis I Leetcode Solution

Difficulty: Easy

Topics: database  

Unfortunately, as an AI language model, I do not have access to the problems and their solutions on LeetCode. However, I can provide some general guidance on how to approach problems like Game Play Analysis I.

To solve a problem like this, you typically need to parse and analyze data in some way. In this case, you are given a table of game play info and asked to find the IDs of players who logged in on the first day and did not return on subsequent days.

One approach to solving this problem could be to first query the table to retrieve the dates each player logged in. You can use the DISTINCT keyword to get a list of unique player IDs, and then use the MIN() function to get the date of the first login for each player. This part of the query might look something like this:

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

Next, you can filter this result set to only include players who logged in on the first day (assuming the timestamp is stored as a Unix epoch time, you can use the DATE() function to extract the date). This part of the query might look something like this:

SELECT player_id FROM ( SELECT DISTINCT player_id, MIN(event_date) AS first_login FROM Activity GROUP BY player_id ) AS p WHERE DATE(FROM_UNIXTIME(p.first_login)) = '2020-01-01'

Finally, you can join this filtered result set with the original table to exclude any players who logged in again on subsequent days. This part of the query might look something like this:

SELECT DISTINCT p.player_id FROM ( SELECT DISTINCT player_id, MIN(event_date) AS first_login FROM Activity GROUP BY player_id ) AS p LEFT JOIN Activity a ON p.player_id = a.player_id AND DATE(FROM_UNIXTIME(a.event_date)) <> '2020-01-01' WHERE DATE(FROM_UNIXTIME(p.first_login)) = '2020-01-01' AND a.player_id IS NULL

Game Play Analysis I Solution Code

1