一个语句搞定,不用临时表
select * from tablename a
where (select count(*) from tablename where testvalue=a.testvalue and uniqueid<=a.uniqueid)<=3
select * from tablename a
where (select count(*) from tablename where testvalue=a.testvalue and uniqueid<=a.uniqueid)<=3
select * from '+@tablename+' a
where (select count(*) from '+@tablename+' where testvalue=a.testvalue and uniqueid<=a.uniqueid)<=3
')
exec('
select * from '+@tablename+' a
where (select count(*) from '+@tablename+' where testvalue=a.testvalue and uniqueid<=a.uniqueid)<=3
order by uniqueid
')
我的EMAIL地址是[email protected]
以后多交流!