用法:
ROW_NUMBER() OVER(partition by col1 order by col2) 表示根据col1分组,在分组内部根据col2排序,而此函数计算的值就表示每组内部排序后的顺序编号(组内是连续且唯一的)
SELECT
PRORDER AS 计划月份,
ROW_NUMBER () OVER ( PARTITION BY prorder ORDER BY PRORDER asc ) CNO,
SPONO AS 电压等级
FROM MES_PTC_VIEW_PROJECT_PLAN WHERE 1=1
ORDER BY prorder,SPONO,PROJECTNO,TRUE_DATE