数据分类 前N条 大概有一个这样的表cid names,types第三个字段是分类 求第一分类的前N条数据 cid不一定连续 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from tb t where cid in(select top n cid from tb where types=t.types order by cid) --2005select * from (select rn=row_number()over(partition by types order by cid),* from tb) t where rn<=n SELECT * FROM @a a WHERE cid in(SELECT TOP 3 htrq FROM @a WHERE types=a.types ORDER BY cid) select * from tb t whre (select count(*)from tb where types=t.types and cid>t.cid)<3 select * from tb t where (select count(*)from tb where types=t.types and cid>t.cid)<3 如何实现'A' + 1 = 'B' 请教一条SQL语句,按天排序,某天为空怎样返回0 如何将表格存入数据库,急! 菜鸟求救,还是触发器的问题 想要取一个表第N列的内容,怎么写啊??? varchar类型结尾空格的问题? 救命啊!急求sqlserver 6.5 请问怎么在sqlserver的用户子定义中是用循环啊! Select * from (select * from Table) ?????????????????????? 在MSSQL中,怎么才能取得某一天的日期!不能有时间! 一个菜菜的问题~~~这个表 怎么做查询 sql查询
select * from tb t where cid in(select top n cid from tb where types=t.types order by cid)
from tb t
whre (select count(*)from tb where types=t.types and cid>t.cid)<3
from tb t
where (select count(*)from tb where types=t.types and cid>t.cid)<3