做人简单 做事认真

Starting a Business Stop Worrying Keep Track Close the Door Never Say No Just Work Harder
posts - 318, comments - 46, trackbacks - 0, articles - 30
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

SQL Server Top Clause 分页查询 Paging

Posted on 2007-10-30 10:27 晓光.NET 阅读(221) 评论(0)  编辑 收藏 所属分类: Database

写出一条Sql语句: 取出表A中第31到第40记录(SQLServer, 以自动增长的ID作为主键,  注意:ID可能不是连续的。)

4.  解1:  select top 10 * from A where id not in (select top 30 id from A)
    解2:  select top 10 * from A where id > (select max(id) from (select top 30 id from A )as A)
    评分标准: 写对即10分。(答案不唯一,datagrid 分页可能需要用到)

We all know the "TOP" clause returns the first n number of rows or percentage of rows thereby limiting the number of resulting rows displayed when we are selecting rows in a table.


标题  
姓名  
主页
Email (只有博主才能看到) 
验证码 *  看不清,换一张 [登录][注册]
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交      
该文被作者在 2007-10-30 16:57 编辑过