sqlserver,查询第N到M条记录,其中ID为唯一
2013-03-25 22:58
260 查看
1、SELECT TOP m-n+1 *
FROM Score
WHERE (id NOT IN
(SELECT TOP n-1 id
FROM Score))
2、select top M-N * from yourTable where id not in(select top N-1 id from table)
3、select top M-N * from 表名 where id in (select distinct(id) from 表名)
有时间记录下,上面三种方法,只用了第一种就没再试了。
FROM Score
WHERE (id NOT IN
(SELECT TOP n-1 id
FROM Score))
2、select top M-N * from yourTable where id not in(select top N-1 id from table)
3、select top M-N * from 表名 where id in (select distinct(id) from 表名)
有时间记录下,上面三种方法,只用了第一种就没再试了。
相关文章推荐
- SQL 分页查询语句大全即(查找第N到M条记录的方法)
- 查询出多条记录,取最大或最小的某条件的记录,取唯一记录
- 转载:如何写个SQL语句查询一个字段里是否有重复记录如果有只读取其中一条记录
- Data Base sqlServer 查询表中31到40的记录,考虑id不连续的情况
- SQL根据Id来查询一条记录或全部记录
- SqlServer查询数据库所有用户表的记录数
- pig中查询top k,返回每个hour和ad_network_id下最大两个记录(SUBSTRING,order,COUNT_STAR,limit)
- 如何写出一条SQL语句:取出表A中第31~40条记录(SQLServer,以自动增长的ID作为主键
- Oracle 删除重复数据只留一条 查询及删除重复记录的SQL语句 1、查找表中多余的重复记录,重复记录是根据单个字段(Id)来判断 select * from 表 wher
- thinkPHP5.0查询id在某个数组中的记录
- mysql查询某一字段出现次数前十的记录id
- Sqlserver查询重复记录
- 添加新记录并判断唯一时:必须是查询批次中的第一个语句
- sqlserver -- 学习笔记(五)查询一天、一周、一个月记录(DateDiff 函数)(备忘)
- 查询所有表的记录数SQLServer
- SQLServer 分组查询相邻两条记录的时间差
- 数据库选取第N到第N+M条记录[2004年7月10日 20:03]
- 步步为营:SQLServer查询随机不相同的记录插入临时表
- ID有多条记录导致用于副表 连接查询时会出现重复
- 记录一次SqlServer查询优化的过程(聚合索引的使用)