i can not join #Temp with scr_SecuristLog. How can i do it?
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 VisitingCount, [Time]
from #Temp as t
left outer join (
select count(page) as VisitingCount,
(datepart(hour,Date)*60+datepart(minute,Date))/30 as [Time]
from scr_SecuristLog
where Date between '2009-05-04' and '2009-05-05'
) as s
on t.VisitingCount = s.VisitingCount
and t.Time = s.Time
This Codes give error:
Msg 8120, Level 16, State 1, Line 1
Column 'scr_SecuristLog.Date' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 8120, Level 16, State 1, Line 1
Column 'scr_SecuristLog.Date' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'VisitingCount'.
Msg 209, Level 16, State 1, Line 1
Ambiguous column name 'Time'.