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 2000 Forums
 SQL Server Development (2000)
 IIf logic in select statements

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-03-06 : 11:27:11
Steve writes "In MS Access (97,2000) its possible to do this:

SELECT Account_Num, Sum( IIf( IsNull([Cancelled]), [PaidAmount], 0 )) AS Payment_Total
FROM Account_Payments
GROUP BY Account_Num

Basically this shows a sum of the total payment, but takes into consideration any cancellatons. If a payment was cancelled, the query still needs to show the account number but with a zero Payment_Total.

I'd like to know if there's an easy way of using ISNULL (and/or COALESCE) to do the same in MSSQL7 in a single statement?

BTW, EXCELLENT website!"
   

- Advertisement -