当前位置:网站首页>mysql rank() over,dense_ rank() over,row_ The difference between number () and over
mysql rank() over,dense_ rank() over,row_ The difference between number () and over
2022-04-22 04:55:00 【Rowing little general】
mysql rank() over,dense_rank() over,row_number() over The difference between
The origin of the problem

Get ready
-- ----------------------------
-- Table structure for scores
-- ----------------------------
DROP TABLE IF EXISTS `scores`;
CREATE TABLE `scores` (
`id` int NOT NULL AUTO_INCREMENT,
`course` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT ' Course ',
`student_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT ' name ',
`score` bigint NOT NULL COMMENT ' fraction ',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_0900_ai_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of scores
-- ----------------------------
INSERT INTO `scores` VALUES (1, ' mathematics ', ' Zhang San ', 100);
INSERT INTO `scores` VALUES (2, ' mathematics ', ' Li Si ', 95);
INSERT INTO `scores` VALUES (3, ' mathematics ', ' Wang Wu ', 99);
INSERT INTO `scores` VALUES (4, ' mathematics ', ' Zhao Liu ', 91);
INSERT INTO `scores` VALUES (5, ' mathematics ', ' 66 ', 100);
SET FOREIGN_KEY_CHECKS = 1;

first :rank() over
Parallel ranking 、 I can jump
SELECT
course,
student_name,
score ,
rank() over(ORDER BY score desc ) as ' ranking '
FROM
scores;

the second 、dense_rank() over
Rank side by side , Don't jump
SELECT
course,
student_name,
score ,
DENSE_RANK() over(ORDER BY score desc ) as ' ranking '
FROM
scores;

Third 、row_number() over
Don't repeat ranking
SELECT
course,
student_name,
score ,
row_number() over(ORDER BY score desc ) as ' ranking '
FROM
scores;

版权声明
本文为[Rowing little general]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210737502731.html
边栏推荐
- 【图像分割综述】Image Segmentation Using Deep Learning: A Survey
- 2022 P cylinder filling training questions and answers
- Realization of online Preview PDF file function
- Flutter installation summary
- rsync概述
- 2021-08-14
- Kaggle actual combat 4.1 -- time series prediction problem
- 【Pytorch】torch. Bmm() method usage
- Opencv usage record of neural network learning
- Autojs cannot connect to the computer, prompting that the connection failed and the permission is insufficient
猜你喜欢

How can devices of different brands be compatible and interconnected? Yiwen teaches you to understand

Transaction isolation level and mvcc

Visio setting network topology

【板栗糖GIS】arcmap—模型构造器—批量裁剪栅格数据

JVM——》CMS

【Selenium】UnitTest测试框架的基本应用

Solve the problem of category imbalance in classification
![[SQL Server accelerated path] database and table (II)](/img/5a/cb54c5ca894820ab46b02d4c0ee346.png)
[SQL Server accelerated path] database and table (II)

【板栗糖GIS】supermap—如何為數據制造超鏈接

EMO-DB 数据集的 Speech 特征提取
随机推荐
cv2.drawContours()、cv2.findContours()、cv2.boundingRect(img)函数用法解析
Spark 入门程序 : WordCount
Summary of 2019 personal collection Framework Library
论文阅读-Access Pattern disclosure on Searchable Encryption: Ramification, Attack and Mitigation(2012)
style/TextAppearance.Compat.Notification.Info) not found.
2022 P cylinder filling training questions and answers
How to get the creator and other information of PNG pictures, not just the file size and other information That is, how to obtain the metadata of the picture
Carina 的根基与诞生背景|深入了解 Carina 系列 第一期
rsync概述
Leetcode refers to offer 65 No addition, subtraction, multiplication and division***
Kaggle actual combat 4.1 -- time series prediction problem
Chapter 2 MySQL data types and operators
Wos opens the way, and Weimeng makes a new way for SaaS in China
Deployment of web server, personal experience
Cloud network integration - computing power center - roce / rmda and nvme / nvme of
Chapter I overview of database
Inotify Brief
2021-08-14
How to realize different values and display different colors in MATLAB
Inotify简述