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.
| Author |
Topic |
|
kirkeby
Yak Posting Veteran
57 Posts |
Posted - 2001-10-02 : 11:56:02
|
| Could someone please tell me why the math in the following is not working? SELECT COUNT(SR.Survey_ID)AS IDs, COUNT(CASE SR.optReceive WHEN 'V74' THEN 1 ELSE NULL END)AS V74, COUNT(CASE SR.optReceive WHEN 'V75' THEN 1 ELSE NULL END) AS V75, COUNT(CASE SR.optReceive WHEN 'V76' THEN 1 ELSE NULL END) AS V76INTO #percentDetailFROM SurveySResponses SRSELECT IDs, V74, V75, V76, CONVERT(decimal(3,0), ((V74/IDs) * 100)) AS V74P, CONVERT(decimal(3,0), ((V75/IDs) * 100)) AS V75P, CONVERT(decimal(3,0), ((V76/IDs) * 100)) AS V76PFROM #percentDetailDROP TABLE #percentDetailThe value of IDs is 6, the value of V74 is 2, the value of V75 is 3, and the value of V76 is 1 (and the values of those show correctly when this is executed). I'm getting ZEROES for the calculations (V74P, V75P, and V76P), when the results should be 33, 50 and 17, respectively. Thank you for any assistance! |
|
|
|
|
|
|
|