select *from (select emp.*,row_number() over(partition by deptno order by rownum) cn from emp)where cn = 1;