sql怎么查询一个表中中间的数据

[复制链接]
查看11 | 回复2 | 2010-11-28 16:55:05 | 显示全部楼层 |阅读模式
sql怎么查询一个表中中间的数据。只有一个表。一共24行。我想查询第12行到第24行。还有第25行到第36行的数据。请问用select语句怎么写。这个好像不难不过我不记得了。很急。在线等啊。
1L order不能这样用的吧。

回复

使用道具 举报

千问 | 2010-11-28 16:55:05 | 显示全部楼层
select top 12 * from (select top 24 * from table order by id ) order by id desc 先正序取前24条,再倒序取其中的前12条 ,25-36之间在数据改一个地方:select top 12 * from (select top 36 * from table order by id ) order by id desc
回复

使用道具 举报

千问 | 2010-11-28 16:55:05 | 显示全部楼层
需要一个排序字段 select top 25* from (select top 36* from table1 order by id)order by id desc select * from table1 t1 where (select count(*) from table1 where id<t1.id) between 11
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行