--一等奖学金
select top 2 cpcj_xh as 一等奖学金
from cpcj
where cpcj_bjh = '0304' and 
      cpcj_xnh = '03-04'and
      cpcj_flag = 0
order by cpcj_cpcj DESC--二等奖学金
select top 4 cpcj_xh as 二等奖学金
from cpcj
where cpcj_xh not in
             (select top 2 cpcj_xh
              from cpcj
              where cpcj_bjh = '0304' and 
                    cpcj_xnh = '03-04'and
                    cpcj_flag = 0
              order by cpcj_cpcj DESC) and
      cpcj_bjh = '0304' and
      cpcj_xnh = '03-04' and
      cpcj_flag = 0
order by cpcj_cpcj DESC --三等奖学金
select top 8 cpcj_xh as 三等奖学金
from cpcj
where cpcj_xh not in
             (select top 6 cpcj_xh
              from cpcj
              where cpcj_bjh = '0304' and
                    cpcj_xnh = '03-04' and
                    cpcj_flag = 0
              order by cpcj_cpcj DESC) and
      cpcj_bjh = '0304' and
      cpcj_xnh = '03-04'
order by cpcj_cpcj DESC

解决方案 »

  1.   

    select top 2 cpcj_xh as 一等奖学金select cpcj_xh as 一等奖学金
    from (
       select cpcj_xh 
        from cpcj
        where cpcj_bjh = '0304' and 
              cpcj_xnh = '03-04'and
              cpcj_flag = 0
        order by cpcj_cpcj DESC
    ) where rownum <= 2
      

  2.   

    多了点
    select cpcj_xh as 一等奖学金
    from (
       select cpcj_xh 
        from cpcj
        where cpcj_bjh = '0304' and 
              cpcj_xnh = '03-04'and
              cpcj_flag = 0
        order by cpcj_cpcj DESC
    ) where
      

  3.   

    太郁闷了,
    select cpcj_xh as 一等奖学金
    from (
       select cpcj_xh 
        from cpcj
        where cpcj_bjh = '0304' and 
              cpcj_xnh = '03-04'and
              cpcj_flag = 0
        order by cpcj_cpcj DESC
    ) where rownum <= 2
      

  4.   

    一看结果就知道ORACLE在语句上是多么的麻烦MSSQL在中小型应用上就是好