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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 query help

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2010-11-25 : 12:16:26
select d.mydate,d.pcn,d.phone,d.amount,d.reason from declinedpayments d left join payments p on p.p=d.p and p.received<mydate where d.mydate>'20100923'


what I want this to do is show all records from declinedpayments where there is not a record in payments that received is more then mydate in declinedpayments

what am I doing wrong in the above query?

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2010-11-25 : 12:21:59
is received a date field? Does it contain nulls?

select d.mydate,d.pcn,d.phone,d.amount,d.reason
from declinedpayments d
left join payments p on p.p=d.p
where d.mydate>'20100923' and (p.received<mydate or p.received is null)

Might need to post actual results vs expected results...




Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2010-11-25 : 12:57:35
thanks :)

that was an easy one..
Go to Top of Page
   

- Advertisement -