Sql Query

  • Thread starter Thread starter Madhu Gangaiah
  • Start date Start date
M

Madhu Gangaiah

I need to find the Maximun Number of Call for the Time Frame, My table
is like this

Create Table Call
( callid varchar(10), TimeStart Datetime, TimeEnd Datetime)

Insert into call values('1001', '2003-07-14 00:22:27', '2003-07-14
00:27:20')
Insert into call values('1002', '2003-07-14 01:25:47', '2003-07-14
01:32:27')
Insert into call values('1003', '2003-07-14 01:35:22', '2003-07-14
01:45:22')
Insert into call values('1004', '2003-07-14 03:55:57', '2003-07-14
03:59:27')
Insert into call values('1005', '2003-07-14 05:05:21', '2003-07-14
05:21:29')
Insert into call values('1006', '2003-07-14 07:07:20', '2003-07-14
07:22:27')
Insert into call values('1007', '2003-07-14 08:15:00', '2003-07-14
08:22:27')

output should be like

TimeFrame NoofCalls

1:00 - 2:00 2

Time Frame - Time Period like 1:00 AM to 2:00 AM
 
try something like this
for calls starting from or after 1am and ending on or before 2am e.g.
select count(*) from call where datepart(dd,timestart)=14 and
datepart(hh,timestart)>=1 and (datepart(hh,timeend)<=1 or
(datepart(hh,timeend)=2 and datepart(mi,timeend)=0 and
datepart(ss,timeend)=0 ))

manipulate according to ur need.
Rajesh
 
Back
Top