Solved

# Get Count By Time Slot

Posted on 2011-03-02
403 Views
Hi
I have the following raw data
Date         Number Of Calls          Average Wait Time(seconds)
1-Feb-10      2                        7.12
2-Feb-10      5                        10.2
3-Feb-10      20                        19.02
4-Feb-10      2                         2.33
5-Feb-10      1                         0.09
6-Feb-10      6                         1.12
7-Feb-10      8                         8.34

and I wish to get this from the raw data

Wait Time Slot      Number of Calls
< 5 seconds                            9
5 - 10 seconds      10
10 - 15 seconds      5
15 - 20 seconds      20

Has anyone any ideas about something clever I can do with SQL and the RANK() function or something to get the data grouped and totaled by the different Wait Time slots?

0
Question by:Barry Cunney
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

LVL 18

Expert Comment

ID: 35018847
If the first set of data is raw data, then the breakdown of how that average was achieved is not there, and I can't see how you can do that.

for example on 3rd feb, you need to know ho long each of those 50 calls lasted
0

LVL 32

Expert Comment

ID: 35018863
try this
``````select [Number Of Calls], TimeSlot
from
(select [Number Of Calls],
case
when [Average Wait Time] < 5 then
'<6'
when [Average Wait Time] < 11 then
'6-10'
when [Average Wait Time] < 16 then
'11-15'
when [Average Wait Time] < 21 then
'16-20'
end as TimeSlot
from  table1) A
group by A.[Number Of Calls], A.TimeSlot
``````
0

LVL 32

Accepted Solution

Ephraim Wangoya earned 500 total points
ID: 35018882
Include sum
``````select SUM([Number Of Calls]) as [Number Of Calls], TimeSlot
from
(select [Number Of Calls],
case
when [Average Wait Time] < 5 then
'<6'
when [Average Wait Time] < 11 then
'6-10'
when [Average Wait Time] < 16 then
'11-15'
when [Average Wait Time] < 21 then
'16-20'
end as TimeSlot
from  table1) A
group by A.[Number Of Calls], A.TimeSlot
``````
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
###### Suggested Courses
Course of the Month7 days, 4 hours left to enroll