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 |
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-03-29 : 08:29:07
|
| Table NameID Data11 Yes2 No3 NAHere's my formulaSELECT SUM(CASE Data1 WHEN 'yes' THEN 1 ELSE 0 END) / (SUM(CASE Data1 WHEN 'yes' THEN 1 ELSE 0 END) + (SUM(CASE Data1 WHEN 'no' THEN 1 ELSE 0 END) + (SUM(CASE Data1 WHEN 'na' THEN 1 ELSE 0 END))))FROM Test3I can't seem to have a quotion of .33333. Can any one help me? |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-03-29 : 08:51:38
|
| I'm getting 2 as the result. I think it's the position of the parenthesis "()' |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-03-29 : 09:43:38
|
SELECT SUM(CASE Data1 WHEN 'yes' THEN 1.0 ELSE 0.0 END) / (SUM(CASE Data1 WHEN 'yes' THEN 1.0 ELSE 0.0 END) + SUM(CASE Data1 WHEN 'no' THEN 1.0 ELSE 0.0 END) + SUM(CASE Data1 WHEN 'na' THEN 1.0 ELSE 0.0 END))FROM Test3 E 12°55'05.25"N 56°04'39.16" |
 |
|
|
cutiebo2t
Constraint Violating Yak Guru
256 Posts |
Posted - 2008-03-29 : 10:06:55
|
| i think it works. thanks |
 |
|
|
|
|
|