select itemid,rank() over (PARTITION by type order by itemid) rank1
from tablename
where rank1<=10

解决方案 »

  1.   

    select * from  (select * from lhg where id=1) a where rownum < 11
    union
    select * from  (select * from lhg where id=2) a where rownum < 11
    union
    select * from  (select * from lhg where id=3) a where rownum < 11
      

  2.   

    试了一下,有点问题。
    rank1 不能在条件里面直接用。select * from
    (select itemid,rank() over (PARTITION by type order by itemid) as rank1
    from tablename) a
    where a.rank1<=10
      

  3.   

    select * from  (select * from lhg where id=1) a where rownum < 11
    union
    select * from  (select * from lhg where id=2) a where rownum < 11
    union
    select * from  (select * from lhg where id=3) a where rownum < 11这种用法不是很好,只能临时用用。
    通常这种情况下typeid总是有很多,而且是可变的。在程序里是不可能这么用的。
      

  4.   

    select * from  (select * from lhg where id=1) a where rownum < 11
    union
    select * from  (select * from lhg where id=2) a where rownum < 11
    union
    select * from  (select * from lhg where id=3) a where rownum < 11
    可行,