Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

case statement question 2

Status
Not open for further replies.

rds80

Programmer
Nov 2, 2006
124
US
In the case statement below I expect the result to be blank when CM.Cost is NULL or = to .0000. But when CM.Cost = .0000, I get the value as 0%.

LA.Numerator isn't equal to 0, so that isnt the problem.
Code:
COALESCE(dbo.udfFormatPct(
            (SELECT CASE WHEN CM.Cost IS NULL OR CM.Cost = .0000 THEN ''
                 ELSE CONVERT(varchar, (LA.Numerator/CM.Cost) * 100) END 
             FROM tblControlMaster CM
             INNER JOIN @LoanAmount LA
                ON LA.ControlID = CM.ControlID
             WHERE LA.NoteID = N.NoteID), 0, 1), '')

Any suggestions? or more info I could provide.

Thanks.
 
D'oh I was using varchar when I tested that last one :-(

Sorry RDS

Ignorance of certain subjects is a great part of wisdom
 
Where are you trying to display this data? Is it possible zeroes could be replaced on your front end? (Hint - the answer is yes ;-) ) That would probably be much less painful than throwing a million converts into your calculation, no?

Ignorance of certain subjects is a great part of wisdom
 
The data is being copied and pasted into excel on a weekly basis. Since it's a weekly basis, it's easier to copy and paste the data without doing a replace all and instead have these conversions.

Besides going thru this exercise I got to learn about why money is accurate to the thousandths, giving varchar a default value, the nullif, coalesce, and how to do simple verifications...Of course thanks to you guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top