id      name      sal      deptno
1 a 100
2 10
3 a 10
4 10
5 a 100 10想要结果
        id         name     sal     deptno  
         1   a 100 10
2 a 100 10
3 a 10
4 10
5
with temp as(
select 1 id, 'a' name,100 sal,null deptno from dual
union all
select 2 id, null name,null sal,10 deptno from dual
union all
select 3 id, 'a' name,null sal,10 deptno from dual
union all
select 4 id, null name,null sal,10 deptno from dual
union all
select 5 id, 'a' name,100 sal,10 deptno from dual
)

解决方案 »

  1.   

    select * from temp order by name,sal,deptno
      

  2.   

    楼主贴的数据不太清楚,不知一下是不是楼主要的ID NAME SAL DEPTNO
    1 a 100
    2 10
    3 a 10
    4 10
    5 a 100 10select a.id,b.name,c.sal,d.deptno
    from 
    (select id,rownum rn from tb   order by id) a
    join (select name,rownum rn from (select name  from tb  order by name desc nulls last)t) b on a.rn=b.rn  
    join (select sal,rownum rn from (select sal  from tb  order by sal desc nulls last)t) c on a.rn=c.rn 
    join (select deptno,rownum rn from (select deptno  from tb  order by deptno desc nulls last)t) d on a.rn=d.rn 
    order by a.id 
    ;ID NAME SAL DEPTNO
    1 a 100 10
    2 a 100 10
    3 a 10
    4 10
    5
      

  3.   

    数据:
    id name sal deptno
    1   a   100 
    2             10
    3   a         10
    4             10
    5   a   100   10
    想要的结果:id name sal deptno
    1   a   100  10
    2   a   100  10
    3   a        10
    4            10
    5         
    不知道这样,大家清楚了吗?