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 |
ahmedpower
Starting Member
6 Posts |
Posted - 2012-12-11 : 07:26:08
|
Hi TeamHow I can Adding Total Table for Many Field as below query.Select CT.EnterpriseName, Sum(ISNULL(CTHH.CallsOfferedHalf,0)) CallOfferedMonthly, Sum(ISNULL(CTHH.CallsAnsweredToHalf,0)) CallAnsweredMonthly, Sum(ISNULL(CTHH.RouterCallsAbandQToHalf,0)) CallsAbandMonthly, Avg(case when CTHH.CallsAnsweredToHalf=0 or CTHH.CallsAnsweredToHalf is null then 0 else ISNULL(CTHH.TalkTimeHalf,0)/CTHH.CallsAnsweredToHalf end) as AvgTalkTimeMonthly, Avg( case when CTHH.RouterCallsAbandQToHalf=0 or CTHH.RouterCallsAbandQToHalf=null then 0 else ISNULL(CTHH.CallDelayAbandTimeToHalf,0)/CTHH.RouterCallsAbandQToHalf end) as AvgAbandWaitTimeMonthly, Avg(case when CTHH.CallsAnsweredToHalf=0 or CTHH.CallsAnsweredToHalf is null then 0 else ISNULL(CTHH.AnswerWaitTimeHalf,0)/CTHH.CallsAnsweredToHalf end) as AvgAnswerWaitTimeMonthly, Avg(ISNULL(CTHH.ServiceLevelHalf,0)) ServiceLevelMonthly fromCall_Type CTinner join Call_Type_Half_Hour CTHH on CT.CallTypeID = CTHH.CallTypeID and CTHH.DateTime between '11/1/2012' and '11/30/2012'where CT.CallTypeID IN (5006, 5007, 5012, 5011, 5008, 5009)Group by CT.EnterpriseNameRight now I got only seperate but also i need the Total.ThanksAhmed Soliman |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2012-12-11 : 08:21:22
|
You mean you need total for all columnpost your question in this format:http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-12-11 : 08:33:39
|
per EnterpriseName for sum of calls?tot = Sum(ISNULL(CTHH.CallsOfferedHalf,0)) +Sum(ISNULL(CTHH.CallsAnsweredToHalf,0)) +Sum(ISNULL(CTHH.RouterCallsAbandQToHalf,0)) Total for all EnterpriseNames?Add a with rollup after the group by.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
|
|
|
|
|