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
 General SQL Server Forums
 New to SQL Server Programming
 Compound Conditions

Author  Topic 

Jason Carlton Aguilar
Starting Member

5 Posts

Posted - 2012-02-06 : 10:57:07
I am really confused on the following question regarding compound conditions.
Write a SELECT statement that determines whether the PaymentDate column of the Invoices table has any invalid values. To be valid, PaymentDate must be a null value if there's a balance due and a non-null value if there's no balance due. Code a compound condition in the WHERE clause that tests for these conditions.

Thanks for any help with this.
JCA

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-06 : 11:35:27
[code]
SELECT columns...
FROM table
WHERE NOT((PaymentDate IS NULL AND COALESCE([balance due],0) >0)
OR (PaymentDate IS NOT NULL AND COALESCE([balance due],0) =0))
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -