为幸福写歌

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

分页查询很简单,具体代码如下:

--分页查询

--查询1-3行数据
select top 3 * from emp order by sal desc;

--查询4-6行数据
select top 3 *
	from emp
	where empno not in (select top 3  empno from emp order by sal desc)
	order by sal desc;

--查询7-9行数据
select top 3 *
	from emp
	where empno not in (select top 6  empno from emp order by sal desc)
	order by sal desc;
--查询10-12行数据
select top 3 *
	from emp
	where empno not in (select top 9  empno from emp order by sal desc)
	order by sal desc;

--查询13-14行数据
select top 3 *
	from emp
	where empno not in (select top 12  empno from emp order by sal desc)
	order by sal desc;

 

posted on 2016-08-21 22:34  为幸福写歌  阅读(326)  评论(0编辑  收藏  举报