Here's what I'm running now, it should be giving me all the parts that have sold between today and 2 years ago. What's wrong with my query?
这是我现在要做的,它应该给我所有在今天和两年前出售的部分。我的查询有什么问题?
SELECT PART_ID
FROM CUST_ORDER_LINE
WHERE PROMISE_DATE BETWEEN (GETDATE()) AND (SELECT DATEADD(yyyy, -2, GETDATE()))
2 个解决方案
#1
3
it should be in reverse order . the oldest date should come first.
它应该是反向的。最古老的约会应该先来。
SELECT PART_ID
FROM CUST_ORDER_LINE
WHERE PROMISE_DATE BETWEEN (DATEADD(yyyy, -2, GETDATE())) and (GETDATE())
#2
2
You don't need a SELECT in either (SELECT DATEADD(yyyy, -2, GETDATE()))
it can be just
您也不需要SELECT(选择DATEADD(yyyy, -2, GETDATE())),它可以是just。
(DATEADD(yyyy, -2, GETDATE()))
#1
3
it should be in reverse order . the oldest date should come first.
它应该是反向的。最古老的约会应该先来。
SELECT PART_ID
FROM CUST_ORDER_LINE
WHERE PROMISE_DATE BETWEEN (DATEADD(yyyy, -2, GETDATE())) and (GETDATE())
#2
2
You don't need a SELECT in either (SELECT DATEADD(yyyy, -2, GETDATE()))
it can be just
您也不需要SELECT(选择DATEADD(yyyy, -2, GETDATE())),它可以是just。
(DATEADD(yyyy, -2, GETDATE()))