drop table #t1 create table #t1 ( h int unique ) declare @hh int set @hh = 0 while(@hh < 24) begin insert into #t1(h) values (@hh) set @hh = @hh + 1 endselect #t1.h, count(all ip) from #t1 left join log on #t1.h=datepart(hour,log.[hour]) group by #t1.h order by #t1.h
我也不大清楚,是不是这样呢?? select datepart(hour,getdate()) as hour,count(*) as count ,isnull(count,0) from log group by hour
drop table #t1 create table #t1 ( h int unique ) declare @hh int set @hh = 0 while(@hh < 24) begin insert into #t1(h) values (@hh) set @hh = @hh + 1 end delete from log where (datepart(Hour,hour)) = 0select #t1.h, count(all ip) from #t1 left join log on #t1.h=datepart(hour,log.[hour]) group by #t1.h order by #t1.h
0 0
create table #t1
(
h int unique
)
declare @hh int
set @hh = 0
while(@hh < 24)
begin
insert into #t1(h) values (@hh)
set @hh = @hh + 1
endselect #t1.h, count(all ip)
from #t1 left join log
on #t1.h=datepart(hour,log.[hour])
group by #t1.h
order by #t1.h
select datepart(hour,getdate()) as hour,count(*) as count ,isnull(count,0)
from log
group by hour
drop table #t1
create table #t1
(
h int unique
)
declare @hh int
set @hh = 0
while(@hh < 24)
begin
insert into #t1(h) values (@hh)
set @hh = @hh + 1
end
delete from log where (datepart(Hour,hour)) = 0select #t1.h, count(all ip)
from #t1 left join log
on #t1.h=datepart(hour,log.[hour])
group by #t1.h
order by #t1.h