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)
 Case statement causing / by zero problem

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-08-14 : 13:34:16
Nancy writes "In the following statement &STFR = 2001
&MOTO = 2001
&STFR = 7
&MOTO = 8
This is giving a zero in this statement. How can I say -- when zero then one -- within the case statement?

 COUNT(*) /
CASE
WHEN YEAR(&STFR) = YEAR(&MOTO)
THEN MONTH(&STFR) - MONTH(&MOTO) + 1
ELSE 6 + MONTH(&MOTO)
END AS AVG_YTD_POL


Thanks!"
   

- Advertisement -