Oracle分组编号查询
原始数据
coml1 coml2 coml3
-----------------------------------
101 a 1
102 b 1
103 c 1
104 d 2
105 e 2
查询完
ROWNUM coml1 coml2 coml3
------------------------------------
1 101 a 1
2 102 b 1
3 103 c 1
1 104 d 2
2 105 e 2
按照coml3分组编号..
------解决方案--------------------
使用分析函数可以完成你的需求,不过你没有说明你的编号是按哪列排序,我假设是按coml1
SQL code
SELECT ROW_NUMBER() OVER(PARTITION BY COLM3 ORDER BY COML1),COML1,COML2,COML3 FROM TALBE;
------解决方案--------------------
SQL code
select coml1, coml2, coml3, row_number() over(partition by coml3 order by coml1) rn from tab1