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