当前位置:网站首页>SQL练习 2022/7/5
SQL练习 2022/7/5
2022-08-04 05:28:00 【Provence°_博】
SQL练习 2022/7/5
584. 寻找用户推荐人
题干
代码思路
- 嵌套查询
select name
from customer
where id not in(
select id
from customer
where referee_id =2
)
- 直接查询
SELECT name FROM customer WHERE referee_id != 2 OR referee_id IS NULL;
586. 订单最多的客户
题干
代码思路
- 分组排序,然后取第一条
select a.customer_number from
(select customer_number ,count(order_number) as cnt
from Orders
group by customer_number
order by cnt desc
limit 1)as a
- 开窗函数
select customer_number from (
select
customer_number,
dense_rank() over(order by count(*) desc) as rn
from orders
group by customer_number
) temp where rn = 1;
select a.customer_number from
(select customer_number,dense_rank() over(order by count(*) desc)as rn
from Orders
group by customer_number
limit 1)as a
边栏推荐
猜你喜欢
随机推荐
对象存储-分布式文件系统-MinIO-1:概念
ES6 Const Let Var的区别
flink sql left join数据倾斜问题解决
Oracle备份脚本
ThinkPHP5.0.x 反序列化分析
k3s-轻量级Kubernetes
flink on yarn任务迁移
再识关联容器
CAS与自旋锁、ABA问题
Unity动画生成工具
JS代码预编译
【树 图 科 技 头 条】2022年6月28日 星期二 伊能静做客树图社区
FFmpeg源码分析:avformat_open_input
跳转页面实时调用后台接口,更新页面数据
IP地址查询
php将多维数据保存进json文件
大龄程序员的心理建设
webrtc中的任务队列TaskQueue
Embedded system driver primary [4] - under the basis of character device driver _ concurrency control
登录页面js手写