511. Game Play Analysis I
Game Play Analysis I
透過leetcode 511
Game Play Analysis I來練習
使用table
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
(player_id, event_date) 是這個表的主鍵。
這張表顯示了一些遊戲玩家的活躍度。
每一行都是玩家在某天使用某些設備註銷之前登錄並玩了許多遊戲(可能為 0)的記錄。
題目說明:
編寫 SQL 查詢以報告每個玩家的首次登錄日期。
按任意順序返回結果表。
查詢結果格式位於以下範例中。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
解題:
以下為第一個例題 43.44%
- select
MIN(M.EVENT_DATE)
(最小值)
- GROUP BY 起來 (依M.PLAYER_ID)
以下為第二個例題 72.11%
select 2次
- 先將Activity資料表處理 加入id排序(依照M.EVENT_DATE) ROW_NUMBER()
ROW_NUMBER() OVER(PARTITION BY M.PLAYER_ID ORDER BY M.EVENT_DATE)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
- 再select出id = 1 的就是各玩家初次登入日期
By. @UEW2WaUHTqSmPOSfnfXrNw