这一篇是对前面所有关于分析函数的文章的总结:
一、统计方面:
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?)
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?])
??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开发专题之:分析函数2(Rank, Dense_rank, row_number) 》
三、最大值/最小值查找方面:
Min()/Max()?Keep?(Dense_rank?First/Last?[Partition?by?]?[Order?by?])
具体请参考《Oracle应用专题之:分析函数3(Top/Bottom N、First/Last、NTile) 》
四、首记录/末记录查找方面:
First_value?/?Last_value(Sum()?Over?([Patition?by?]?[Order?by?]
???????Rows?Between??Preceding?And??Following??))
???????Rows?Between??Preceding?And??Following??))
具体请参考《Oracle开发专题之:窗口函数》
五、相邻记录之间比较方面:
Lag(Sum(),?1)?Over([Patition?by?]?[Order?by?])
具体请参考《Oracle开发专题之:窗口函数》
?
转载自:http://www.blogjava.net/pengpenglin/archive/2008/06/29/211491.html