A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 梦ing 中级黑马   /  2012-12-19 23:35  /  2446 人查看  /  11 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

如题。。。。。。。。。。。。。。。。。。。。。。。。。。。。

评分

参与人数 1技术分 +1 收起 理由
郑文 + 1

查看全部评分

11 个回复

倒序浏览
select * from table where id>30 and id <40;随便写写的

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
郑文 黑马帝 2012-12-20 01:11:52
藤椅
select  *  from
(SELECT   Id ,Name, Age,row_number() over(order by id) as rownum
FROM table) as t
where t.rownum>=30 and t.rownum <=40

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
此帖很水啊,哈哈
回复 使用道具 举报
select  top 10* from Table
where Id not in (select top 30 Id from Table orderby Age desc)
oerder byAge desc

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
select top 10 * from T_user
where id not in (select top 30 * from T_user order by id desc)//先查出前30条数据的ID  在查询不在这30条中的 排名为10条的数据 就是30-40 间的数据
order by id;

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
梦ing 中级黑马 2012-12-24 15:56:09
7#
Sailing. 发表于 2012-12-20 00:15
select * from table where id>30 and id

id不是按顺序排的了
回复 使用道具 举报
sql如何获得第30到40条之间的数据 。。。
select  top 10* from Table
where Id not in (select top 30 Id from Table orderby Age desc)
oerder byAge desc

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
梦ing 中级黑马 2012-12-24 16:01:41
9#
郑文 发表于 2012-12-20 01:11
select  *  from
(SELECT   Id ,Name, Age,row_number() over(order by id) as rownum
FROM table) as t

SELECT   Id ,Name, Age,row_number() over(order by id) as rownum
FROM table
这里的这句是什么意思 row_number() 为啥要加括号  这里的over又是什么意思了啊  不是很懂
回复 使用道具 举报
梦ing 中级黑马 2012-12-24 16:03:01
10#
苏波 发表于 2012-12-20 12:31
select  top 10* from Table
where Id not in (select top 30 Id from Table orderby Age desc)
oerder by ...

嗯,这是个方法,了解
回复 使用道具 举报
梦ing 中级黑马 2012-12-24 16:04:03
11#
唐海军 发表于 2012-12-20 14:02
select top 10 * from T_user
where id not in (select top 30 * from T_user order by id desc)//先查出前 ...

恩恩,谢谢,懂了,注释很不错,给了思路
回复 使用道具 举报
用and或者between关键字进行查询

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马