我有以下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)
之后添加它时,我也会收到错误。
我在哪里将其添加到查询中? 感谢
答案 0 :(得分: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