plsql 分析函式總結
阿新 • • 發佈:2019-01-10
這一篇是對前面所有關於分析函式的文章的總結:
一、統計方面:
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 )
二、排列方面:
Rank() Over ([Partition by... ] [Order by ...] [Nulls First/Last])
Dense_rank() Over ([Patition by ...] [Order by ...] [Nulls First/Last])
Row_number() Over ([Partition by ...] [Order by ...] [Nulls First/Last])
Ntile(...) Over ([Partition by ...] [Order by ...])
三、最大值/最小值查詢方面:
Min(...)/Max(...) Keep (Dense_rank First/Last [Partition by ...] [Order by ...])
四、首記錄/末記錄查詢方面:
First_value / Last_value(Sum(...) Over ([Patition by ...] [Order by... ]
Rows Between ... Preceding And ... Following ))
五、相鄰記錄之間比較方面:
Lag(Sum(...), 1) Over([Patition by... ] [Order by ...])
轉載:http://www.blogjava.net/pengpenglin/archive/2008/06/29/211491.html