OVER (PARTITION BY)函数

    

1、over函数的写法:

     over(partition by class order by sroce) 按照sroce排序进行累计,order by是个默认的开窗函数,按照class分区。

     2、开窗的窗口范围:

     over(order by sroce range between 5 preceding and 5 following):窗口范围为当前行数据幅度减5加5后的范围内的。

     over(order by sroce rows between 5 preceding and 5 following):窗口范围为当前行前后各移动5行。

    sum() over(partition by … order by …):求分组后的总和。 
     first_value() over(partition by … order by …):求分组后的第一个。 
     last_value() over(partition by … order by …):求分组后的最后一个。 
     count() over(partition by … order by …):求分组后的总数。 
     max() over(partition by … order by …):求分组后的最大值。 
     min() over(partition by … order by …):求分组后的最小值。 
     avg() over(partition by … order by …):求分组后的平均值。 
     lag() over(partition by … order by …):取出前n行数据。   
     lead() over(partition by … order by …):取出后n行数据。
 

你可能感兴趣的:(oracle)