CREATE TABLE #Temp (VisitingCount int, [Time] int )
DECLARE @DateNow DATETIME,@i int,@Time int
set @DateNow='00:00'
set @i=1;
while(@i<48)
begin
set @DateNow = DATEADD(minute, 30, @DateNow)
set @Time = (datepart(hour,@DateNow)*60+datepart(minute,@DateNow))/30
insert into #Temp(VisitingCount,[Time]) values(0,@Time )
set @i=@i+1
end
select Sum(VisitingCount)as VisitingCount, [Time]
from #Temp group by [Time]
Union All
select count(page) as VisitingCount,
(datepart(hour,Date)*60+datepart(minute,Date))/30 as [Time]
from scr_SecuristLog
where Date between '2009-05-04 10:30' and '2009-05-04 12:30'
GROUP BY (datepart(hour,Date)*60+datepart(minute,Date))/30--scr
order by 2 asc
This query creates me this table but if you look below "22" is repeating two times. in this situation. i should drop 0 value. i need
VisitingCount ------------Time----------repeating------------------repeating-----
repeating------------------repeating-----
repeating------------------repeating-----
526-----------------------21----------
0--------------------------22----------
0--------------------------22----------
0--------------------------23----------
825------------------------23----------
repeating------------------repeating-----
repeating------------------repeating-----
i need this Table
VisitingCount ------------Time----------repeating------------------repeating-----
repeating------------------repeating-----
repeating------------------repeating-----
526-----------------------21----------
0--------------------------22----------
825------------------------23----------
repeating------------------repeating-----
repeating------------------repeating-----