1 Star 0 Fork 0

逸扬/leetcode-hub-mysql

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
lc-1890.test 1.08 KB
Copy Edit Raw Blame History
逸扬 authored 3 years ago . 511-586-1741-1890 (4)
# 1890. 2020年最后一次登录
# https://leetcode-cn.com/problems/the-latest-login-in-2020/
# SQL架构
Create table If Not Exists Logins (user_id int, time_stamp datetime);
Truncate table Logins;
insert into Logins (user_id, time_stamp) values ('6', '2020-06-30 15:06:07');
insert into Logins (user_id, time_stamp) values ('6', '2021-04-21 14:06:06');
insert into Logins (user_id, time_stamp) values ('6', '2019-03-07 00:18:15');
insert into Logins (user_id, time_stamp) values ('8', '2020-02-01 05:10:53');
insert into Logins (user_id, time_stamp) values ('8', '2020-12-30 00:46:50');
insert into Logins (user_id, time_stamp) values ('2', '2020-01-16 02:49:50');
insert into Logins (user_id, time_stamp) values ('2', '2019-08-25 07:59:08');
insert into Logins (user_id, time_stamp) values ('14', '2019-07-14 09:00:00');
insert into Logins (user_id, time_stamp) values ('14', '2021-01-06 11:59:59');
# Write your MySQL query statement below
select
user_id,
max(time_stamp) as last_stamp
from
Logins
where
year(time_stamp) = '2020'
group by
user_id;
# clean-up
drop table Logins;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gdut_yy/leetcode-hub-mysql.git
git@gitee.com:gdut_yy/leetcode-hub-mysql.git
gdut_yy
leetcode-hub-mysql
leetcode-hub-mysql
master

Search