Leetcode Note: MySQL - Game Play Analysis I

Game Play Analysis I - LeetCode
https://leetcode.com/problems/game-play-analysis-i/

  • MySQL で取り組んだメモ

所感

  • Activity Table から event_date の速いものを player_id をユニークなものとして取得する

回答

Simple Solution - LeetCode Discuss
https://leetcode.com/problems/game-play-analysis-i/discuss/1929577/Simple-Solution

SELECT player_id, min(event_date) AS first_login
FROM activity 
GROUP BY player_id
  • min で最も古い event_date を取得しつつ GROUP BY で play_id 毎にまとめる