SQL语句如下:
SELECT TOP 10 id, Name, Title,Content FROM (SELECT TOP 20 id, Name, Title,Content FROM GuestBook ORDER BY id DESC) ORDER BY id ASC我的思路如下:
每页显示10条,现在要显示第二页的内容,首先选出前20条记录,用TOP 20关键字,用DESC逆序排列,然后再用TOP 10在刚才的记录集中选出前十个,再用ASC顺序排列,
可执行的时候选出的总是前10条记录,请问是什么原因?

解决方案 »

  1.   

    思路是没错你在SQLServer里调试看看……
      

  2.   

    是有问题,你的Select子句所检索出的结果是按倒序排的没错,但你再捡取前10个时,又用order ASC排了,就是说,从20个取10个时,排序是顺序而非倒序,所以还是那10个.
      

  3.   

    SELECT TOP 10 id, Name, Title,Content FROM (SELECT TOP 20 id, Name, Title,Content FROM GuestBook ORDER BY id DESC) ORDER BY id ASC
    这句sql 好像都不能执行...
    ---
    Server: Msg 156, Level 15, State 1, Line 6
    Incorrect syntax near the keyword 'order'.
      

  4.   

    你这样排序其实并不好。.
     可以select Top 10 from Table where Table_ID not in(Select Top 10 Table_ID from table ) order by...