第一:
select ROW_NUMBER() OVER (ORDER BY a.字段 ASC) AS XUHAO,a.* from table a
(table 为表名,字段为表a中的字段名)
第二:
select RANK() OVER (ORDER BY a. 字段 ASC) AS XUHAO,a.* from table a
(table 为表名,字段为表a中的字段名)
例:
SELECT
ROW_NUMBER() OVER (ORDER BY gvicode asc) AS idx,
r.ncode,
g.gvicode,
sum(qtc) qtc
FROM salshiporder r,salshiporderg g WHERE r.salshipicode=g.salshipicode AND r.status='70' AND r.sheetcode='27.15.40.10' group by r.ncode,g.gvicode
效果图:
同样地,另一个方法也适用。