File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -145,6 +145,7 @@ Useful for preparing for technical interviews and improving your SQL skills.
145145 - [ 1741. Find Total Time Spent by Each Employee] ( ./leetcode/easy/1741.%20Find%20Total%20Time%20Spent%20by%20Each%20Employee.sql )
146146 - [ 1789. Primary Department for Each Employee] ( ./leetcode/easy/1789.%20Primary%20Department%20for%20Each%20Employee.sql )
147147 - [ 1795. Rearrange Products Table] ( ./leetcode/easy/1795.%20Rearrange%20Products%20Table.sql )
148+ - [ 1890. The Latest Login in 2020] ( ./leetcode/easy/1890.%20The%20Latest%20Login%20in%202020.sql )
148149 - [ 1965. Employees With Missing Information] ( ./leetcode/easy/1965.%20Employees%20With%20Missing%20Information.sql )
149150 - [ 1978. Employees Whose Manager Left the Company] ( ./leetcode/easy/1978.%20Employees%20Whose%20Manager%20Left%20the%20Company.sql )
150151 - [ 2356. Number of Unique Subjects Taught by Each Teacher] ( ./leetcode/easy/2356.%20Number%20of%20Unique%20Subjects%20Taught%20by%20Each%20Teacher.sql )
Original file line number Diff line number Diff line change 1+ /*
2+ Question 1890. The Latest Login in 2020
3+ Link: https://leetcode.com/problems/the-latest-login-in-2020/description/?envType=problem-list-v2&envId=database
4+
5+ Table: Logins
6+
7+ +----------------+----------+
8+ | Column Name | Type |
9+ +----------------+----------+
10+ | user_id | int |
11+ | time_stamp | datetime |
12+ +----------------+----------+
13+ (user_id, time_stamp) is the primary key (combination of columns with unique values) for this table.
14+ Each row contains information about the login time for the user with ID user_id.
15+
16+
17+ 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.
18+
19+ Return the result table in any order.
20+ */
21+
22+ SELECT
23+ user_id,
24+ MAX (time_stamp) AS last_stamp
25+ FROM Logins
26+ WHERE time_stamp::varchar LIKE ' 2020%'
27+ GROUP BY user_id
You can’t perform that action at this time.
0 commit comments