Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
bholmstrom
Yak Posting Veteran
76 Posts |
Posted - 2013-03-01 : 14:38:19
|
Good afternoon. I have a query that needs to filter out any records that do not have a modifydate entry after 1/1/2009Here are the code:select a.account,b.modifydatefrom sql1.sysdba.Account Aleft 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.Sorry for the long explanation, any ideas ?ThanksBryan Holmstrom |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-03-01 : 16:37:18
|
[code]SELECT a.account,b.modifydateFROM 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);[/code] |
|
|
|
|
|