select sysdate, row_number() over(partition by sysdate order by case when trunc(sysdate) >= trunc(sysdate) then '0' else '1' end) as rn from dual