0

我有以下 SQL

  SELECT * FROM ( 
   select id,ROW_NUMBER() OVER (ORDER BY id) as row 
   from order where 
       (shopkeeper=116363) and (status > 0) and 
       (status <> 2) and 
       [creationdate] >= convert(datetime,'06/07/2013 00:00:01',103) and
       [creationdate] <= convert(datetime,'20/07/2013 23:59:59',103) ) a 
  WHERE row BETWEEN 1 AND 100 

我想在这个查询中添加一个“按 ID 排序”,但是当我将它添加到末尾时,我得到一个错误,当我在<= convert(datetime,'20/07/2013 23:59:59',103)我也得到一个错误之后添加它时。

我在哪里将它添加到查询中?谢谢

4

1 回答 1

0

尝试这个

    SELECT * FROM ( 
       select id,ROW_NUMBER() OVER (ORDER BY id) as row 
       from order where 
         (shopkeeper=116363) and 
         (status > 0) and (status <> 2) and 
         [creationdate] >= convert(datetime,'06/07/2013 00:00:01',103) and 
         [creationdate] <= convert(datetime,'20/07/2013 23:59:59',103) ) a 
    WHERE row BETWEEN 1 AND 100 
    Order by a.Id
于 2013-08-07T10:53:11.053 回答