日期:2014-05-17  浏览次数:20804 次

pl/sql developer如何在结果集中体现?
如:
  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 dual
union all
select 1 id, 101 pri from dual
union all
select 2 id, 12 pri from dual
union all
select 2 id, 14 pri from dual
union all
select 2 id, 18 pri from dual
)select row_number() over (partition by id order by pri) num, id, pri from a;