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
 Transact-SQL (2000)
 complex CASE statement

Author  Topic 

qwertyjjj
Posting Yak Master

131 Posts

Posted - 2007-11-29 : 08:46:01
If this whole statement evaluates to < 0 then I need to put in the value 0 otherwise I need to run what is in the current case statement.
DO I need to repeat the whole lot again?

CASE
WHEN ISNULL(ZI.InvoicesRaised,0) <=0 THEN 0
ELSE CASE
WHEN ISNULL(ZA.TotalDebt,0) <> 0 THEN CASE
WHEN (ISNULL(ZA.TotalDebt,0) - ISNULL(ZI.InvoicesRaised,0)) > 0 THEN 30
ELSE ((ISNULL(ZA.TotalDebt,0) * 30) / ISNULL(ZI.InvoicesRaised,0))
END
ELSE 0
END
END

Ifor
Aged Yak Warrior

700 Posts

Posted - 2007-11-29 : 11:40:44
[code]CASE
WHEN ISNULL(ZI.InvoicesRaised,0) <= 0
THEN 0
WHEN ISNULL(ZA.TotalDebt,0) <> 0
CASE
WHEN (ISNULL(ZA.TotalDebt,0) - ISNULL(ZI.InvoicesRaised,0)) > 0
THEN 30
WHEN ((ISNULL(ZA.TotalDebt,0) * 30) / ISNULL(ZI.InvoicesRaised,0)) > 0
THEN ((ISNULL(ZA.TotalDebt,0) * 30) / ISNULL(ZI.InvoicesRaised,0))
ELSE 0
END
END[/code]
Go to Top of Page
   

- Advertisement -