/*------------------------------------------
over子句只能用于select和order by 查询阶段,且只能和聚合函数和排名函数(譬如row_number(),dense_rank()) 配合使用
over子句中只包含两种语法,over(partition by userid order by userid),partition by 和order by
partition by 用于分组,具体用法见下面的例子
order by 用于和排名函数配合使用时,按照什么排名顺序来进行分配序号
------------------------------------------*/
---用于聚合函数
select userid,deptid,remitspan,askspan,outspan,(remitspan+askspan+outspan) as totalvalue
,sum(remitspan+askspan+outspan) over(partition by deptid) as teamvalue
,sum(remitspan+askspan+outspan) over() as alltotal
from overtest
转载于:https://www.cnblogs.com/friendship-chenwei/archive/2010/08/30/1812572.html