请问各位高手,以下的情况应该怎么进行处理?谢谢了
--------------------------
declare @sdate datetime,@edate datetime
set @sdate='2007-02-02 00:00:00.000'
set @edate='2007-02-02 23:59:57.000'select
分布小时段=a.period,
PV访问量=count(b.pageview),
独立用户=count(distinct b.sessionid),
独立IP = count(distinct b.fromip),
比例=rtrim(cast(count(b.pageview)*100.0/
(select count(*) from #tt where LoginTime between @sdate and @edate) as numeric(5,2)))+'%'
from time_period a left join
(select * from #tt where LoginTime between @sdate and @edate)b
on a.hh=datepart(hh,LoginTime)
group by a.period
以上的语句得到这样的结果:
---------------------------------------------------------
时间段 页面流量 独立用户数 独立IP数 访问比例
00:00-01:00 1792 528 517 3.11%
01:00-02:00 1003 314 311 1.74%
02:00-03:00 823 237 205 1.43%
03:00-04:00 696 170 163 1.21%
04:00-05:00 439 108 106 0.76%
05:00-06:00 277 99 98 0.48%
06:00-07:00 336 113 113 0.58%
07:00-08:00 434 141 124 0.75%
08:00-09:00 1383 374 373 2.40%
09:00-10:00 1911 561 551 3.31%但是对一些表却出现这样的错误信息:
------------------------------
服务器: 消息 8134,级别 16,状态 1,行 30
遇到被零除错误。
警告: 聚合或其它 SET 操作消除了空值。
--------------------------
declare @sdate datetime,@edate datetime
set @sdate='2007-02-02 00:00:00.000'
set @edate='2007-02-02 23:59:57.000'select
分布小时段=a.period,
PV访问量=count(b.pageview),
独立用户=count(distinct b.sessionid),
独立IP = count(distinct b.fromip),
比例=rtrim(cast(count(b.pageview)*100.0/
(select count(*) from #tt where LoginTime between @sdate and @edate) as numeric(5,2)))+'%'
from time_period a left join
(select * from #tt where LoginTime between @sdate and @edate)b
on a.hh=datepart(hh,LoginTime)
group by a.period
以上的语句得到这样的结果:
---------------------------------------------------------
时间段 页面流量 独立用户数 独立IP数 访问比例
00:00-01:00 1792 528 517 3.11%
01:00-02:00 1003 314 311 1.74%
02:00-03:00 823 237 205 1.43%
03:00-04:00 696 170 163 1.21%
04:00-05:00 439 108 106 0.76%
05:00-06:00 277 99 98 0.48%
06:00-07:00 336 113 113 0.58%
07:00-08:00 434 141 124 0.75%
08:00-09:00 1383 374 373 2.40%
09:00-10:00 1911 561 551 3.31%但是对一些表却出现这样的错误信息:
------------------------------
服务器: 消息 8134,级别 16,状态 1,行 30
遇到被零除错误。
警告: 聚合或其它 SET 操作消除了空值。
分布小时段=a.period,
PV访问量=count(b.pageview),
独立用户=count(distinct b.sessionid),
独立IP = count(distinct b.fromip),
case when c.cnt = 0 then '0.00%' else rtrim(cast(count(b.pageview)*100.0/c.cnt)+'%' end as 比例
from time_period a ,
(select count(*) as cnt from #tt where LoginTime between @sdate and @edate) as numeric(5,2)) c
left join
(select * from #tt where LoginTime between @sdate and @edate)b
on a.hh=datepart(hh,LoginTime)
group by a.period
出现这样的错误信息:
--------------------------------------
服务器: 消息 1035,级别 15,状态 10,行 36
'cast' 附近有语法错误,需要 'AS'。
服务器: 消息 156,级别 15,状态 1,行 38
在关键字 'as' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 40
第 40 行: 'b' 附近有语法错误。