注册 登录
编程论坛 SQL Server论坛

显示第30行到第40行的数据

smofbao 发布于 2007-03-30 13:15, 787 次点击
用SQL语句显示一个表(有数据100行)中第30行到第40行的数据
7 回复
#2
徐强2007-03-30 13:22
select * from (select top 40 主键 from table1) as a where not exists(select top 30 主键 from table1 b where a.主键=b.主键 )
#3
徐强2007-03-30 13:23
top 40 * from
top 30 * from
这样写
#4
daidaidai2007-03-30 14:52

不行,好象没有数据出来.

#5
小水滴2007-03-30 15:02

应该对表进行排序

#6
xiyou4192007-04-03 08:38
select * from (select top 40 * from table1) as a where not exists(select top 30 * from table1)
#7
棉花糖ONE2007-04-03 12:11
没主键的话,这样的问题可能会出现问题.有主键就好办
#8
daring2007-04-10 14:54

select top 10 * from t where primary_key not in(select top 30 primary_key from t)

[此贴子已经被作者于2007-4-10 14:57:31编辑过]

1