select t1,t2 from (select t1,t2 from test where t1 = '1' order by t2 desc) where rownum <= 3
union all
select t1,t2 from (select t1,t2 from test where t1 = '2' order by t2 desc) where rownum <= 3
union all
select t1,t2 from (select t1,t2 from test where t1 = '3' order by t2 desc) where rownum <= 3

解决方案 »

  1.   

    select t.a1,s.a2,v.a3 from (select t2 as a1 from tableName where t1=1 and rownum<4 order by t2) t,(select t2 as a2 from tableName where t1=1 and rownum<4 order by t2) s,(select t2 as a3 from tableName where t1=1 and rownum<4 order by t2) v
      

  2.   

    我这个表是用在新闻存储上的:
    分为新闻类型和新闻发布时间(整型)
    类型为“体育”,财经,政治
    目的想列出所有类型新闻最新发布的几条。感谢:snowy_howe(天下有雪) 不够我想要动态更新类型怎么办?
      

  3.   

    8i以上的话,分析函数应该效率高一些
    SELECT *
    FROM (SELECT a.*,row_number() over(PARTITION BY t1 ORDER BY t2 DESC) rnum 
          FROM yourtable a 
          WHERE a.t1 = 1
             OR a.t1 = 2
             OR a.t1 = 3)
    WHERE rnum <= 3
      

  4.   

    非常感谢大家的帮助,可惜我的环境必须还要支持老的oracle。
    子句中不能用order by.