一、升序
--查询第20到第30条数据(升序,即从第20,21----30)(9=30-20+1)
1
select * from (select top 9* from (select top 30* from dbo.Student order by 学号 asc) as a order by 学号 desc)as b order by 学号 asc
二、降序
--查询第20到第30条数据(降序,即从第30,29----20)
1
select top 9* from (select top 30* from dbo.Student order by 学号 asc) as a order by 学号 desc
三、多表取值
select * from
(
select a.pid,a.pname,isnull(rates,0) rates,path,a.type from product a left outer join (
select pid,sum(rates) rates from rate
group by pid
)b on a.pid=b.pid
) a where type=1