如:
id pri
1 10
1 101
2 12
2 14
2 18
我需要前辈们帮我在结果集中--按id相同给出一个次序号--体现
num id pri
1 1 10
2 1 101
1 2 12
2 2 14
3 2 18
------解决方案--------------------
- SQL code
with a as(select 1 id, 10 pri from dualunion allselect 1 id, 101 pri from dualunion allselect 2 id, 12 pri from dualunion allselect 2 id, 14 pri from dualunion allselect 2 id, 18 pri from dual)select row_number() over (partition by id order by pri) num, id, pri from a;