SQL 查询对比流水单据

SELECT ROW_NUMBER() OVER (ORDER BY FacturaID2 )+200 AS 对比,OrderID, OrderDate, OrderTime, FacturaID3, FacturaID2, Status
FROM Orders
WHERE (FacturaID2 >= 2017005120) AND (FacturaID2 <= 2017005160)
ORDER BY FacturaID2

 

其中:ROW_NUMBER() OVER (ORDER BY FacturaID2 )+200  为 取发票2序列+200

 


SELECT ROW_NUMBER() OVER (ORDER BY FacturaID3 )+0 AS 对比,OrderID, OrderDate, OrderTime, FacturaID3, FacturaID2, Status
FROM Orders
WHERE (FacturaID3 >= 2017000000) AND (FacturaID3 <= 2017100199)
ORDER BY FacturaID3

解释 排列对比发票号3序列,从2017000000开始对比到2017100199