Leetcode Note: MySQL - The Latest Login in 2020

The Latest Login in 2020 - LeetCode
https://leetcode.com/problems/the-latest-login-in-2020/

  • MySQL で取り組んだメモ

回答

Simple MySQL with line explanation - The Latest Login in 2020 - LeetCode
https://leetcode.com/problems/the-latest-login-in-2020/solutions/1262178/simple-mysql-with-line-explanation/

SELECT
    user_id,
    MAX(time_stamp) AS last_stamp #obtaining latest login for all users
FROM Logins
WHERE YEAR(time_stamp) = 2020 #filtering for login dates with year 2020 in timestamp
GROUP BY user_id;