2013-08-07 61 views
0

我有以下SQLSQL服務器的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

什麼是你的錯誤,通過看這應該是工作的罰款查詢,並通過在月底添加順序應該給你的結果,你檢查數據的質量? – aads

回答

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