|
1.
不知道如果不止一个应该怎么显示。。是多行?多列?还是一个列拼起来?
select dep,max(sal),min(sal),
case when count(emp_name) KEEP(DENSE_RANK first ORDER BY sal) =1 then min(emp_name) KEEP(DENSE_RANK first ORDER BY sal) else .. end
from emp1
group by dep
2.
这个是按部门分行打印,不知道是不是需求的意思。。。
又或者是5个一行,无序打印?
select
max(case when rn=1 then EMP_NAME else null end),
max(case when rn=2 then EMP_NAME else null end) ,
max(case when rn=3 then EMP_NAME else null end ),
max(case when rn=4 then EMP_NAME else null end),
max(case when rn=5 then EMP_NAME else null end)
from
( select t.* ,row_number()over(partition by dep order by sal) rn
from emp1 t
)
group by dep |
|