注册 | 登录 忘记密码? 51cto首页 | 博客 | 论坛 | 招聘
热点文章 华硕获奖方案 - 中小企业..
 帮助

SQL Server Top Clause 分页查询 Paging


2008-03-11 10:09:45
 标签:SQL Server   [推送到技术圈]

    写出一条Sql语句: 取出表A中第31到第40记录(SQLServer, 以自动增长的ID作为主键,  注意:ID可能不是连续的。)
    解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.
 
作者:许小光




    文章评论
 
 

发表评论

昵   称:
验证码:  点击图片可刷新验证码  博客过2级,无需填写验证码
内   容: