select top 10 * from table1 where id>=10 order by id不知道行不行,不过声明,我也只是一个初学者。

解决方案 »

  1.   

    你们没明白我的意思,我再说详细些:
    表“基本号码表”中有如下记录(id为PK):
    有语句:select id,openday from 基本号码表id          openday 
    ----------- ------- 
    13          2001080
    2           2001081
    3           2001082
    4           2001083
    5           2001084
    6           2001085
    7           2001086
    8           2001087
    9           2001088
    10          2001089
    11          2001090
    12          2001091
    15          2001093
    20          2001094
    21          2001095
    22          2001096
    23          2001097
    14          2001092
    (可看出,默认是以openday升序排列)现在要取出openday最大的10个记录,
    id          openday 
    ----------- ------- 
    23          2001097
    22          2001096
    21          2001095
    20          2001094
    15          2001093
    14          2001092
    12          2001091
    11          2001090
    10          2001089
    9           2001088
    所以有如下语句:
    select a.* from (select top 10 id,openday from 基本号码表 order by openday desc) as a order by a.openday asc
    上面的结果有个问题,即是以openday降序在排列,但我要求是升序(外层的asc没起作用),即:2001088、2001089...2001097
    刚才只不过为了简化问题,所以只提了一个字段。
    注:id只是用来表示唯一性,要求只从openday考虑。
      

  2.   

    上微软网站上把sql server 2000的sp2当下来,安装上就好了。
      

  3.   

    我的是 SQL Server7.0,与这有关?(再次试了,还是那样)
      

  4.   

    select count(*) from 基本号码表  as a where  (select count(*) from 基本号码表  as b where  a.openday<b.openday )<10
      

  5.   

    你嵌套的
    select top 10 id,openday from 基本号码表 order by openday desc
    取出的只是最小的十个,当然不对,
    你可以改成升序,或取最后十个