over (partition by)
班級表
求各個班級的第一名分數。
其中子查詢出來的資料如下:
rank()和dense_rank()的區別是:
--rank()是跳躍排序,有兩個第二名時接下來就是第四名
--dense_rank()l是連續排序,有兩個第二名時仍然跟著第三名
row_number() over(partition by ... order by ...)
rank() over(partition by ... order by ...)
dense_rank() over(partition by ... order by ...)
count() over(partition by ... order by ...)
max() over(partition by ... order by ...)
min() over(partition by ... order by ...)
sum() over(partition by ... order by ...)
avg() over(partition by ... order by ...)
first_value() over(partition by ... order by ...)
last_value() over(partition by ... order by ...)
lag() over(partition by ... order by ...)
lead() over(partition by ... order by ...)
點選(此處)摺疊或開啟
- select * from class;
求各個班級的第一名分數。
點選(此處)摺疊或開啟
-
select *
-
from (select name,
-
class_no,
-
score,
-
rank() over(partition by class_no order by score desc) rank
-
from class)
- where rank = 1
其中子查詢出來的資料如下:
點選(此處)摺疊或開啟
-
(select name,
-
class_no,
-
score,
-
rank() over(partition by class_no order by score desc) rank
- from class)
rank()和dense_rank()的區別是:
--rank()是跳躍排序,有兩個第二名時接下來就是第四名
--dense_rank()l是連續排序,有兩個第二名時仍然跟著第三名
row_number() over(partition by ... order by ...)
rank() over(partition by ... order by ...)
dense_rank() over(partition by ... order by ...)
count() over(partition by ... order by ...)
max() over(partition by ... order by ...)
min() over(partition by ... order by ...)
sum() over(partition by ... order by ...)
avg() over(partition by ... order by ...)
first_value() over(partition by ... order by ...)
last_value() over(partition by ... order by ...)
lag() over(partition by ... order by ...)
lead() over(partition by ... order by ...)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29990276/viewspace-1660361/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ROWNUMBER() OVER( PARTITION BY COL1
- row_number() OVER (PARTITION BY COL1 ORDER BY COL2)
- sql(oracle)資料處理實用總結開窗函式(over partition)使用SQLOracle函式
- Partition Pruning和Partition-Wise Joins
- Clique Partition
- oracle partition by group by,詳解partition by和group by對比Oracle
- 分割槽Partition
- 7.74 DATAOBJ_TO_PARTITIONOBJ
- 86. Partition List
- oracle partition by 語法Oracle
- B. Range and Partition
- mysql自動排序函式dense_rank() over()、rank() over()、row_num() over()用法和區別MySql排序函式
- Jenkins Publish Over SSHJenkins
- 分析函式系列之sum(col1) over(partition by col2 order by col3):實現分組彙總或遞增彙總函式
- Peace or partition? Cyprus - Espresso EconomistEspresso
- 7.73 DATAOBJ_TO_MAT_PARTITIONOBJ
- 3-Partition 問題
- {"error":400,"message":"over quota"}Error
- Review: Red Star over ChinaView
- Codeforces 1948E Clique Partition
- 分割槽partition知識點
- Partition|Disk Utility 如何分割磁碟
- 10G DG SWITCH OVER
- Include manifest for over-the-air installationAI
- SQL-ROWNUMBER-OVER彙總SQL
- MQTT over QUIC 多流支援MQQTUI
- Flink SQL之Over 聚合操作SQL
- Spark學習——分割槽Partition數Spark
- [LeetCode] 416. Partition Equal Subset SumLeetCode
- [Over-Distance] Ubuntu 24.04 LTS UpdateUbuntu
- vue.js mouse over change the imageVue.js
- [20210315]acknowledge over PGA limit.txtMIT
- Oracle Partition 分割槽詳細總結Oracle
- PostgreSQL DBA(94) - PG 12 Improving Partition(Select)SQL
- PostgreSQL DBA(93) - PG 12 Improving Partition(Insert)SQL
- 分割槽函式Partition By的基本用法函式
- Kafka分割槽分配策略(Partition Assignment Strategy)Kafka
- [ARC190B] L Partition 題解
- Spark Streaming--開窗函式over()Spark函式