這一篇是對前面所有關於分析函數的文章的總結:
一、統計方面:
復制代碼 代碼如下:Sum() Over ([Partition by ] [Order by ])
Sum() Over ([Partition by ] [Order by ]
Rows Between Preceding And Following)
Sum() Over ([Partition by ] [Order by ]
Rows Between Preceding And Current Row)
Sum() Over ([Partition by ] [Order by ]
Range Between Interval '' 'Day' Preceding
And Interval '' 'Day' Following )
具體請參考《Oracle開發之分析函數簡介Over用法》和《Oracle開發之窗口函數》
二、排列方面:
復制代碼 代碼如下:Rank() Over ([Partition by ] [Order by ] [Nulls First/Last])
Dense_rank() Over ([Patition by ] [Order by ] [Nulls First/Last])
Row_number() Over ([Partitionby ] [Order by ] [Nulls First/Last])
Ntile() Over ([Partition by ] [Order by ])
具體請參考《Oracle開發之分析函數(Rank, Dense_rank, row_number)》
三、最大值/最小值查找方面:
復制代碼 代碼如下:Min()/Max() Keep (Dense_rank First/Last [Partition by ] [Order by ])
具體請參考《Oracle開發之分析函數(Top/Bottom N、First/Last、NTile)》
四、首記錄/末記錄查找方面:
復制代碼 代碼如下:First_value / Last_value(Sum() Over ([Patition by ] [Order by ]
Rows Between Preceding And Following ))
具體請參考《Oracle開發之窗口函數》
五、相鄰記錄之間比較方面:
復制代碼 代碼如下:Lag(Sum(), 1) Over([Patition by ] [Order by ])
具體請參考《Oracle開發之報表函數》
以上就是Oracle分析函數總結的全部內容,希望能給大家一個參考,也希望大家多多支持幫客之家。