SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Adding Total Table for Many Field
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ahmedpower
Starting Member

Qatar
6 Posts

Posted - 12/11/2012 :  07:26:08  Show Profile  Reply with Quote
Hi Team

How 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

from
Call_Type CT
inner 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.EnterpriseName




Right now I got only seperate but also i need the Total.

Thanks

Ahmed Soliman

sodeep
Flowing Fount of Yak Knowledge

USA
7174 Posts

Posted - 12/11/2012 :  08:21:22  Show Profile  Reply with Quote
You mean you need total for all column
post your question in this format:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

nigelrivett
Flowing Fount of Yak Knowledge

United Kingdom
3355 Posts

Posted - 12/11/2012 :  08:33:39  Show Profile  Visit nigelrivett's Homepage  Reply with Quote
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.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000