| Author |
Topic  |
|
|
ahmedpower
Starting Member
Qatar
6 Posts |
Posted - 01/06/2013 : 07:55:15
|
Hi SQL Team
I am really straggle to get the total and average for any Query as well I tried with union all keywords for the 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 DateTime Between '2013-01-01 00:00:00' and '2013-01-05 23:59:59' where CT.CallTypeID IN (5006, 5007, 5012, 5011, 5008, 5009) Group by CT.EnterpriseName
Please advise only how to get total and average as i will really Appricate your support.
Ahmed Soliman |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47173 Posts |
Posted - 01/06/2013 : 10:13:16
|
the logic looks fine. can you explain what you mean by total and average ot working? give some sample data and explain the expected and current obtained values
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
|
jardrake
Starting Member
3 Posts |
Posted - 01/07/2013 : 02:42:21
|
Your using sum() and avg(), which means you know what you are doing with the functions. Like visakh16 said, the logic looks fine, what does SQL say is the problem?
I am a writer for the SQL Tutorial and Reference (http://www.afterhoursprogramming.com/tutorial/SQL/Overview/) section of afterhoursprogramming.com |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47173 Posts |
|
|
ahmedpower
Starting Member
Qatar
6 Posts |
Posted - 01/07/2013 : 11:25:07
|
Can you write the syntax for me as i can test it , Please as I am not profession like that complecated Syntax
Ahmed Soliman |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
India
47173 Posts |
Posted - 01/07/2013 : 11:31:14
|
post some sample data and your expected output without which i'm not sure what you're after!
------------------------------------------------------------------------------------------------------ SQL Server MVP http://visakhm.blogspot.com/
|
 |
|
| |
Topic  |
|