当前位置:网站首页>ROW_ NUMBER()、RANK()、DENSE_ Rank difference
ROW_ NUMBER()、RANK()、DENSE_ Rank difference
2022-07-02 16:27:00 【Mu code text】
ROW_NUMBER()、RANK()、DENSE_RANK difference
ROW_NUMBER(): Sort , There will be no duplicate sorting values . For two equal numbers , Sequence number is inconsistent
| The number | Sort sequence number |
|---|---|
| 1 | 1 |
| 1 | 2 |
| 2 | 3 |
select
id,
row_number()
over(order by id) rn
from
data
DENSE_RANK(): Sort , There may be duplicate values . For two equal numbers , The sequence number is consistent
| The number | Sort sequence number |
|---|---|
| 1 | 1 |
| 1 | 1 |
| 2 | 2 |
select
id,
dense_rank()
over(order by id) rn
from
data
RANK(): Sort , There may be duplicate values . For two equal numbers , The sequence number is consistent , But the total will decrease
| The number | Sort sequence number |
|---|---|
| 1 | 1 |
| 1 | 1 |
| 2 | 3 |
select
id,
rank()
over(order by id) rn
from
data
If in the window over() No sort field , So what's the result ?
select
id,
rank()
over()
from
data
| The number | Sort sequence number |
|---|---|
| 1 | 1 |
| 1 | 1 |
| 2 | 1 |
If in the window over() No sort field , It uses row_number() Sort , What is the result? ?
select
id,
row_number()
over()
from
data
| The number | Sort sequence number |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 1 | 3 |
The reason for this phenomenon :
stay over() Window , All numerical orders are the same . about rank Because repetition is allowed , So it's all 1, and row_number() There will be no duplicate sort sequence number , So it will 1,2,3,4, etc. , But the result of each sorting is different .
边栏推荐
- Yyds dry inventory company stipulates that all interfaces use post requests. Why?
- OSPF - route aggregation [(summary) including configuration commands] | address summary calculation method - detailed explanation
- Bone conduction non ear Bluetooth headset brand, bone conduction Bluetooth headset brand recommendation
- Bean configuration override in boot
- Boot 中bean配置覆盖
- Seal Library - installation and introduction
- After the win10 system is upgraded for a period of time, the memory occupation is too high
- 【5G NR】RRC连接释放
- Invalid bound statement (not found) solution summary
- 做机器视觉哪个软件好?
猜你喜欢

Effectively use keywords to increase Amazon sales

The median salary of TSMC's global employees is about 460000, and the CEO is about 8.99 million; Apple raised the price of iPhone in Japan; VIM 9.0 releases | geek headlines

Aujourd'hui dans l'histoire: Alipay lance le paiement par code à barres; La naissance du père du système de partage du temps; La première publicité télévisée au monde...

idea 公共方法抽取快捷键

Boot 事务使用

2022最新最详细必成功的在Vscode中设置背景图、同时解决不受支持的问题

Mysql database mysqldump why there is no statement to create a database

mysql min() 求某条件下最小的值出现多个结果

自注意力机制和全连接的图卷积网络(GCN)有什么区别联系?

Typescript array out of order output
随机推荐
Boot 连接 Impala数据库
Vscade set multi line display of tab
[Xiaobai chat cloud] suggestions on container transformation of small and medium-sized enterprises
sql解决连续登录问题变形-节假日过滤
Register as a harmonios developer and install deveco studio 3.0 beta2 for harmonios
HMS core machine learning service helps zaful users to shop conveniently
Summary of monthly report | list of major events of moonbeam in June
数仓中的维度表与事实表
Huawei ECS installs mysqlb for mysqld service failed because the control process exited with error code. See “sys
Trigger: MySQL implements adding or deleting a piece of data in one table and adding another table at the same time
Rock PI Development Notes (II): start with rock PI 4B plus (based on Ruixing micro rk3399) board and make system operation
Sqlserver queries which indexes are underutilized
绝对真理和相对真理思考
Classifier visual interpretation stylex: Google, MIT, etc. have found the key attributes that affect image classification
仙人掌之歌——投石问路(2)
Remove the underline in router link
idea jar包冲突排查
Boot transaction usage
数学分析_笔记_第5章:一元微分学
[5g NR] RRC connection release