--tryselect * from T as tmp where (select count(*) from T where cCateNo=tmp.cCateNo and cUrlNo<tmp.cUrlNo)<10
select top 10 * from a group by cCateNo
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
where (select count(*) from T where cCateNo=tmp.cCateNo and cUrlNo<tmp.cUrlNo)<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