窗口函数累加递增

select a.OrderNum,a.num,a.CreateTime,b.audittime,
sum(a.num) over(order by a.OrderNum range between unbounded preceding AND CURRENT ROW) as currenttotal from table1 a 
inner join  table2 b on a.OrderNum=b.OrderNum
where ItemNum='111111' and b.IsDelete=0 and b.Status=1 and a.StorageNum='1'

 partition by在over里面实现group by的功能

select itemnum,count(itemnum) over(partition by itemnum) as cnt
from table1

  

posted on 2020-07-20 10:04  fenix  阅读(161)  评论(0编辑  收藏  举报