没有原始表结构,只能以oracle的soctt下的dept与emp为例
with t1 as (select deptno, count(*) employees, avg(sal) avg
from scott.emp group by deptno),
s1 as (select t1.deptno,t2.dname,t1.employees, t1.avg, t3.ename, t3.sal
from t1 join scott.dept t2 on t1.deptno=t2.deptno join scott.emp t3 on t1.deptno=t3.deptno),
s2 as (select case when deptno=lag(deptno) over(order by deptno) then null else deptno end deptno,
case when deptno=lag(deptno) over(order by deptno) then null else dname end dname,
case when deptno=lag(deptno) over(order by deptno) then null else employees end employees,
case when deptno=lag(deptno) over(order by deptno) then null else avg end avg,
ename,sal
from s1)
select * from s2
温馨提示:内容为网友见解,仅供参考