作业帮 > 综合 > 作业

这句select row_number() over (order by ProductID asc) as RowIn

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/28 09:01:52
这句select row_number() over (order by ProductID asc) as RowIndex,
select row_number() over (order by ProductID asc) as RowIndex,
p.ProductID,p.ProductName,p.CategoryID,p.Unit,p.UnitPrice,p.Quantity
from Products as p
where CategoryID = @CategoryID;
这句select row_number() over (order by ProductID asc) as RowIndex,
这个是Oracle中比较常见的用法.
[TEST2@orcl#19-4月 -11] SQL>select * from a;
DTIME RCOUNT
---------- ----------
2011011101 2
2011011101 3
[TEST2@orcl#19-4月 -11] SQL>select row_number()over(order by dtime ) as rowseq,dtime,rcount from a;
ROWSEQ DTIME RCOUNT
---------- ---------- ----------
1 2011011101 3
2 2011011101 2
主要用于查询数据的时候显示序号.
over是Oracle的开窗函数.
over(order by dtime ) 就是按照dtime排序并进行累加.对什么累加呢?就是前面的row_number()系统函数.
你可以再试试sum(列)over(partition by id order by salary)等 可以求工资的累加和.