
分组top n与m到n行的记录
htl258_Tony
这个作者很懒,什么都没留下…
展开
-
取n到m条记录的语句
取n到m条记录的语句1.select top m * from tablename where id not in (select top n id from tablename) 2.select top m * into 临时表(或表变量) from tablename order by columnname -- 将top m笔插入set rowcount nselect * from 表变转载 2009-03-17 16:05:00 · 1403 阅读 · 0 评论 -
获取某数据前n行
declare @t table(id int,class int,marks int)insert @t select 1,1,100 union all select 2,1,92 union all select 3,1,99 union all select 4,1,90 union all select 5,1,99 union all select 6,2,97 union all s转载 2009-03-17 13:47:00 · 1006 阅读 · 0 评论 -
按某一字段分组取最大(小)值所在行的数据
--按某一字段分组取最大(小)值所在行的数据--(爱新觉罗.毓华(十八年风雨,守得冰山雪莲花开) 2007-10-23于浙江杭州)/*数据如下:name val memoa 2 a2(a的第二个值)a 1 a1--a的第一个值a 3 a3:a的第三个值b 1 b1--b的第一个值b 3 b3:b的第三个值b 2 b2b2b2b2b转载 2009-03-23 21:22:00 · 1218 阅读 · 1 评论 -
取n到m条记录的语句
取n到m条记录的语句1.select top m * from tablename where id not in (select top n id from tablename) set rowcount nselect * from 表变量 order by columnname desc2.select top n * from (select top m * from tablename转载 2009-03-28 22:15:00 · 1136 阅读 · 4 评论 -
查每个分组前N条记录
----------------------------------- Author: liangCK 小梁-- Title : 查每个分组前N条记录-- Date : 2008-11-13 17:19:23-----------------------------------> 生成测试数据: #TIF OBJECT_ID(tempdb.dbo.#T) IS NOT NULL DRO转载 2009-04-12 11:45:00 · 1709 阅读 · 0 评论