i have 2 tables who includes thes sames colums but the differentes data.
TOOLS DATE
----------- ----------------------
A10MA17 2021-09-25 05:14:16.000
x10UA50 2021-09-25 05:06:50.000
LU0NV03 2021-09-25 05:04:49.000
NU0MAK8 2021-09-25 05:02:22.000
252WA17 2021-09-25 05:15:12.000
I would like to select the data which is in table (A) but which is not in table (B) at a later date, that is to say the program must select a data in the tables (A) and go see if it does not exist in the tables B at a later date.
i use this request but I don't know how to add the filter on the date
SELECT TOOLS FROM A WHERE A NOT IN (SELECT TOOLS FROM B)
thank's for help
As I mentioned in the comment, I would suggest using a NOT EXISTS
with a correlated subquery:
SELECT A.Tools
FROM dbo.A
WHERE NOT EXISTS (SELECT 1
FROM dbo.B
WHERE B.Tools = A.Tools
AND B.[Date] > A.[Date]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.