Good afternoon. I have a query that needs to filter out any records that do not have a modifydate entry after 1/1/2009
Here are the code:
select a.account,b.modifydate from sql1.sysdba.Account A left outer join sql1.sysdba.Opportunity B ON b.accountid = b.accountid where b.modifydate < '2009-01-01 00:00:00.00'
This code works except in my test data one record has 168 entries in the opportunity table, and some are greater that the above date. What this means is that record "a" should NOT be on the list/output.
SELECT
a.account,b.modifydate
FROM
sql1.sysdba.Account A
inner join sql1.sysdba.Opportunity B
ON b.accountid = b.accountid
WHERE NOT EXISTS
(
SELECT * FROM sql1.sysdba.Opportunity x
WHERE x.modifydate >= '20090101'
AND x.accountid = b.accountid
);