当前位置:网站首页>SQL练习 2022/7/4
SQL练习 2022/7/4
2022-08-04 05:28:00 【Provence°_博】
SQL练习 2022/7/4
197. 上升的温度
代码思路
- 使用日期比较函数
select a.id
from Weather a,Weather b
where DATEDIFF(a.recordDate , b.recordDate ) = 1 and a.Temperature >b.Temperature
#或者
select a.id
from Weather a join Weather b
on DATEDIFF(a.recordDate ,b.recordDate)=1 and a.Temperature >b.Temperature
511. 游戏玩法分析
题干
代码思路:
- group by
select player_id,min(event_date) as first_login
from Activity
group by player_id
- 排名函数一下
- 使用 dense_rank 函数按照 player_id 和 event_date 进行排序,并算出排名将其作为临时表 temp
- 查询临时表 temp,筛选出 排名 = 1 数据
select player_id, event_date as first_login from (
select
player_id,
event_date,
dense_rank()
over(partition by player_id order by event_date) as 排名
from activity
) as temp where 排名 = 1;
边栏推荐
猜你喜欢
随机推荐
BUUCTF——MISC(一)
PHP实现异步执行程序
ThinkPHP5.0.x 反序列化分析
VScode配置PHP环境
The cost of automated testing is high and the effect is poor, so what is the significance of automated testing?
flink-sql自定义函数
浏览器中的同源策略
8.30难题留坑:计数器问题和素数等差数列问题
MySql的concat和group_concat的区别
Unity开发类似Profile那样的数据分析工具
关于let var 和const的区别以及使用
Embedded system driver primary [4] - under the basis of character device driver _ concurrency control
实现登录密码混合动态因子,且动态因子隐式
win云服务器搭建个人博客失败记录(wordpress,wamp)
Lombok的一些使用心得
程序、进程、线程、协程的概念及区别
大龄程序员的心理建设
Upload靶场搭建&&第一二关
ISCC2021——web部分
纳米级完全删除MYSQL5.7以及一些吐槽









