2022-04-08 min,max
2022-04-08 本文已影响0人
16孙一凡通工
min()/max() as 求取当前字段的最大值并输出
1890. 2020年最后一次登录
select user_id,max(time_stamp) as last_stamp from Logins
where time_stamp>'2020-01-01 00:00:00' and time_stamp<'2021-01-01 00:00:00'
group by user_id;
511. 游戏玩法分析 I
select player_id,min(event_date) as first_login
from Activity
group by player_id
586. 订单最多的客户
select customer_number from
(select customer_number,count(*) as cnt
from Orders
group by customer_number)t
order by cnt desc limit 1;