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 |
|
kdeutsch
Yak Posting Veteran
83 Posts |
Posted - 2009-11-03 : 16:35:06
|
| Below is my total query but what I need to accomphish is to find the percentage of 2 fields. This is the working query.Select ud.strUIc, Sum(up.intReqstr) as REQ, Sum(up.intAsgnStr) as ASGN, CAST(CEILING(Sum(up.intAsgnStr)*1.0 / Sum(up.intReqstr) * 100) as varchar) + '%' as 'Percent', Count(CASE WHEN strpara IN ('900') THEN 'O/S' END) as [OS], Select Count(CASE WHEN strPara IN ('900') THEN 'O/S' END) from tblUnitPosition where intAsgnStr = 1) as [O/S Assign], Sum(up.intAsgnStr) + Count(CASE WHEN strpara IN ('900') THEN 'O/S' END) as Total_ASGN, Count(CASE WHEN strFillType in ('DA') THEN 'DA' END) as DA_VAC, Count(CASE WHEN strFillType in ('NGB') THEN 'NGB' END) as NGB_VAC, Count(CASE WHEN strFillType in ('STATE') THEN 'STATE' END) as STATE_VAC from tblData as ud Inner Join tblPosition as up on up.intUnitMobId = ud.intUnitMobId where up.strpara not in ('900') AND up.intUnitMobId = 458Group by strUIcWhat I need to do is find the percentage of teh following 2 fields. Everything I have done has been fo naught. One of the errors that I get is the divide by zero error(Select Count(CASE WHEN strPara IN ('900') THEN 'O/S' END) from tblUnitPosition where intAsgnStr = 1) as [O/S Assign] Count(CASE WHEN strpara IN ('900') THEN 'O/S' END) as [OS] |
|
|
|
|
|