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 |
mohan123
Constraint Violating Yak Guru
252 Posts |
Posted - 2012-11-28 : 08:52:43
|
select * ,case when DimConditionDefinitionId =1 then sum(totalusers/246624)when DimConditionDefinitionId =2 then sum(totalusers/246624)when DimConditionDefinitionId =3 then sum(totalusers/246624)when DimConditionDefinitionId =4 then sum(totalusers/246624)else 0 end as populationcountfrom dbo.pop_fact group by DimConditionDefinitionId,FactPopulationDefinitionId,totalusersWhen i executing these query i am getting population count as '0'Actually i need to get sum values for all conditions suggest meP.V.P.MOhan |
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-11-28 : 09:02:28
|
select*,SUM (CASE WHEN DimConditionDefinitionId between 1 and 4 THEN totalusers ELSE 0 END) /246624.0JimEveryday I learn something that somebody else already knew |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-11-28 : 09:03:01
|
[code] sum(totalusers/246624.0)[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-11-29 : 02:52:38
|
quote: Originally posted by jimf select*,SUM (CASE WHEN DimConditionDefinitionId between 1 and 4 THEN totalusers ELSE 0 END) /246624.0JimEveryday I learn something that somebody else already knew
Also list out required columns and include them in GROUP BY clause too MadhivananFailing to plan is Planning to fail |
|
|
|
|
|