求查询某个表中(10到30)条语句的用法

来源:百度知道 编辑:UC知道 时间:2024/04/23 23:33:48
我学要的是SQL谢谢!select top(30-10) * from(select top 30 * from 表名)as 别名 order by desc
这个语句我记得是.但不太好用
2楼的好象搜索不到哦~~~我试过了:(
select top 8 * from (select top 9 * from NewsContent order by ContentId) order by ContentId desc 这个是我按照3楼的方法做的.好象也不好用:(
4、5楼的都不好用5555...........谁救救我啊?

我来救你!!

use northwind
select * from
(
select top 20 * from
(
select top 30 productid,unitprice from products order by unitprice desc
) as t1
order by unitprice asc
) as t2
order by unitprice desc

子查询用原来的排序方式,取10到30用相反排序
select top 20 <选择列表> from (select top 30 <选择列表> from <表> where <条件> order by <排序列>) where <条件> order by <排序列> desc

试下这个:先按照升序找出30条,在降序找20条,得到的刚好是10-30条.
select top 20 from 表名 where id in(select top 30 from 表名 order by id asc) order by id desc

目前我只知道MYSQL数据库有这样的语法:
select <选择列表> from <表> where <条件> limit 10,30

试试这样

select top 20 * from products where productid not in
(select top 10 productid from products order by unitprice desc)
order by unitprice desc