select id, addr, riqi, row_number()over (partition by riqi order by riqi) as paixu
from
(select 1 id,'AA' addr,20150101 as riqi from dual
union all
select 1 id,'BB' addr,20150201 as riqi from dual) where rownum =1 ;
select id, addr, riqi, row_number()over (partition by riqi order by riqi) as paixu
from
(select 1 id,'AA' addr,20150101 as riqi from dual
union all
select 1 id,'BB' addr,20150201 as riqi from dual) where rownum =1 ;