LeetCode - 1890. The Latest Login in 2020 (MySQL)

조민수·2024년 7월 5일
0

LeetCode

목록 보기
49/61

Easy, SQL - MAX()

RunTime : 528 ms


문제

Write a solution to report the latest login for all users in the year 2020. Do not include the users who did not login in 2020.

Return the result table in any order.

The result format is in the following example.


풀이

  • 핵심은 가장 빠른 날짜는 MAX()를 사용해서 얻을 수 있다는 것이다.
SELECT user_id, MAX(time_stamp) as last_stamp FROM Logins
WHERE YEAR(time_stamp) = '2020'
GROUP BY 1 
profile
사람을 좋아하는 Front-End 개발자

0개의 댓글