当前位置:网站首页>【mysql】mysql中行排序
【mysql】mysql中行排序
2022-07-06 20:50:00 【檀越剑指大厂】
mysql中行排序
1.数据准备
drop table if exists kwan.tmp_learning_mary;
create table if not exists kwan.tmp_learning_mary(
id varchar(10)
, name varchar(10)
,age varchar(10)
, salary int
);
insert into kwan.tmp_learning_mary(id, name, age, salary)
values (1, 'a', 10, 8000);
insert into kwan.tmp_learning_mary(id, name, age, salary)
values (1, 'a2', 11, 6500);
insert into kwan.tmp_learning_mary(id, name, age, salary)
values (2, 'b', 12, 13000);
insert into kwan.tmp_learning_mary(id, name, age, salary)
values (2, 'b2', 13, 4500);
insert into kwan.tmp_learning_mary(id, name, age, salary)
values (3, 'c', 14, 3000);
insert into kwan.tmp_learning_mary(id, name, age, salary)
values (3, 'c2', 15, 20000);
insert into kwan.tmp_learning_mary(id, name, age, salary)
values (4, 'd', 16, 30000);
insert into kwan.tmp_learning_mary(id, name, age, salary)
values (5, 'd2', 17, 1800);
2.编写sql加条件
select
*
from
(
select
*,
row_number() over(partition by id
order by
salary desc) ranking
from
tmp_learning_mary) t
where
t.ranking < 2;

3.编写sql不加条件
select
*
from
(
select
*,
row_number() over(partition by id
order by
salary desc) ranking
from
tmp_learning_mary) t

边栏推荐
- 未来发展路线确认!数字经济、数字化转型、数据...这次会议很重要
- LAB1配置脚本
- ubuntu20安裝redisjson記錄
- 海思3559万能平台搭建:RTSP实时播放的支持
- Flink task exit process and failover mechanism
- 2022年上半年HIT行业TOP50
- 小程序能运行在自有App中,且实现直播和连麦?
- Jerry's FM mode mono or stereo selection setting [chapter]
- Set static IP for raspberry pie
- . Net interface can be implemented by default
猜你喜欢

Confirm the future development route! Digital economy, digital transformation, data This meeting is very important

22. (ArcGIS API for JS) ArcGIS API for JS Circle Collection (sketchviewmodel)

24. (ArcGIS API for JS) ArcGIS API for JS point modification point editing (sketchviewmodel)

About Tolerance Intervals

Set static IP for raspberry pie

小程序能运行在自有App中,且实现直播和连麦?

Sub pixel corner detection opencv cornersubpix

Depth analysis of compilation constants, classloader classes, and system class loaders

R data analysis: how to predict Cox model and reproduce high score articles

ubuntu20安装redisjson记录
随机推荐
Decoration design enterprise website management system source code (including mobile source code)
什么是 BA ?BA怎么样?BA和BI是什么关系?
编译常量、ClassLoader类、系统类加载器深度探析
QT 使用QToolTip 鼠标放上去显示文字时会把按钮的图片也显示了、修改提示文字样式
23.(arcgis api for js篇)arcgis api for js椭圆采集(SketchViewModel)
大白话高并发(二)
Index of MySQL
Set static IP for raspberry pie
Probability formula
Enumeration general interface & enumeration usage specification
校招行测笔试-数量关系
CVPR 2022 best paper candidate | pip: six inertial sensors realize whole body dynamic capture and force estimation
Free PHP online decryption tool source code v1.2
Mobile measurement and depth link platform - Branch
卡尔曼滤波-1
密码学系列之:在线证书状态协议OCSP详解
[colmap] 3D reconstruction with known camera pose
[safe office and productivity application] Shanghai daoning provides you with onlyoffice download, trial and tutorial
C# Task拓展方法
[dpdk] dpdk sample source code analysis III: dpdk-l3fwd_ 001