当前位置:网站首页>[MySQL] row sorting in MySQL
[MySQL] row sorting in MySQL
2022-07-07 03:48:00 【Tanyue Jianzhi Dachang】
mysql Bank of China sort
1. Data preparation
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. To write sql Conditional
select
*
from
(
select
*,
row_number() over(partition by id
order by
salary desc) ranking
from
tmp_learning_mary) t
where
t.ranking < 2;
3. To write sql Without conditions
select
*
from
(
select
*,
row_number() over(partition by id
order by
salary desc) ranking
from
tmp_learning_mary) t
边栏推荐
- RestClould ETL 社区版六月精选问答
- U.S. Air Force Research Laboratory, "exploring the vulnerability and robustness of deep learning systems", the latest 85 page technical report in 2022
- 概率论公式
- Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
- pip只下载不安装
- Delete data in SQL
- 【安全攻防】序列化与反序列,你了解多少?
- 25.(arcgis api for js篇)arcgis api for js线修改线编辑(SketchViewModel)
- 20.(arcgis api for js篇)arcgis api for js面采集(SketchViewModel)
- How to replace the backbone of the model
猜你喜欢
Mathematical induction and recursion
Ubuntu 20 installation des enregistrements redisjson
21.(arcgis api for js篇)arcgis api for js矩形采集(SketchViewModel)
2022夏每日一题(一)
25.(arcgis api for js篇)arcgis api for js线修改线编辑(SketchViewModel)
QT item table new column name setting requirement exercise (find the number and maximum value of the array disappear)
Open3d mesh filtering
小程序能运行在自有App中,且实现直播和连麦?
预处理——插值
On file uploading of network security
随机推荐
注意力机制原理
VHDL implementation of arbitrary size matrix addition operation
Tencent cloud native database tdsql-c was selected into the cloud native product catalog of the Academy of communications and communications
什么是 BA ?BA怎么样?BA和BI是什么关系?
太方便了,钉钉上就可完成代码发布审批啦!
预处理——插值
如何自定义Latex停止运行的快捷键
MySQL storage engine
[security attack and Defense] how much do you know about serialization and deserialization?
维护万星开源向量数据库是什么体验
SSL certificate deployment
编译常量、ClassLoader类、系统类加载器深度探析
Mathematical induction and recursion
亚像素级角点检测Opencv-cornerSubPix
Variables, process control and cursors (MySQL)
About Tolerance Intervals
. Net interface can be implemented by default
QT 项目 表格新建列名称设置 需求练习(找数组消失的数字、最大值)
.net中 接口可以有默认实现了
21. (article ArcGIS API for JS) ArcGIS API for JS rectangular acquisition (sketchviewmodel)