plsql analysis function summary

This one is a summary of all the previous articles on analytic functions:

1. Statistics:

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 )

Second, the arrangement:

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 ...])

3. Find the maximum/minimum value:

Min(...)/Max(...) Keep (Dense_rank First/Last [Partition by ...] [Order by ...])

4. First record/last record search:

First_value / Last_value(Sum(...) Over ([Patition by ...] [Order by... ]
       Rows Between ... Preceding And ... Following  ))

Five, the comparison between adjacent records:

Lag(Sum(...), 1) Over([Patition by... ] [Order by ...])
Reprinted: http://www.blogjava.net/pengpenglin/archive/2008/06/29/211491.html


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324791876&siteId=291194637