表a cUrlNo   vcUrl  vcUrlTitle cCateNo
0101    www.a.com  a          01
0102    www.b.com   b         02
0103    www.c.com   c         01按照cCateNo查找出前十条记录

解决方案 »

  1.   

    --tryselect * from T as tmp
    where (select count(*) from T where cCateNo=tmp.cCateNo and cUrlNo<tmp.cUrlNo)<10
      

  2.   

    select top 10 * from a group by cCateNo
      

  3.   

    create table T(cUrlNo varchar(10), vcUrl varchar(10), vcUrlTitle varchar(10), cCateNo varchar(10))
    insert T select  '0101',    'www.a.com',   'a',          '01'
    union all select '0102',    'www.b.com',   'b',         '02'
    union all select '0103',    'www.c.com' ,  'c',         '01'--每組的第一條
    select * from T as tmp
    where (select count(*) from T where cCateNo=tmp.cCateNo and cUrlNo<tmp.cUrlNo)<1