日期:2014-05-18  浏览次数:20524 次

数量核对不上啊?我写错了么?(iisLog分析 用的LogParser,sql语句和Sqlserver差不多)
ip总数->
SQL code

select COUNT(distinct c-ip) as GueCount from 'F:ex111001.log'


结果->1865

//蜘蛛的ip总数
SQL code

    select COUNT(distinct c-ip) as GueCount from 'F:ex111001.log' where cs(User-Agent) like 
'%baidu%' or cs(User-Agent) like '%Yahoo!+Slurp%' or cs(User-Agent) like '%google%' or cs(User-Agent) like '%
YoudaoBot%' or cs(User-Agent) like '%sogou%' or cs(User-Agent) like '%msnbot%' or cs(User-Agent) like '%
+bingbot%'


结果->569

访客ip总量(代码和蜘蛛总量相似,只是将蜘蛛ip总量的sql语句中like前面加个not,同时or改成and),如下:
SQL code

select COUNT(distinct c-ip) as GueCount from 'F:ex111001.log' where cs(User-Agent) not like '%baidu%' and cs(User-Agent) not like '%Yahoo!+Slurp%' and cs(User-Agent) not like '%google%' and cs(User
-Agent) not like '%YoudaoBot%' and cs(User-Agent) not like '%sogou%' and cs(User-Agent) not like '%msnbot%' and cs(User-Agent) not like '%+bingbot%'


  结果->1304

问题来了,按道理结果应该是 ->【ip总量】 减掉 【蜘蛛的ip总量】,也就是1865-569=1296但是结果却是1304,怎么多出了8个?哪来的?希望高手帮忙想想...

------解决方案--------------------
是不是有null值影响?把条件中的列判断一下是否为空,sql server的话,可以isnull()
------解决方案--------------------
or like
and not like 
不是减法用算,仔细考虑下。
------解决方案--------------------
具体要看数据才能分析出原因
 
------解决方案--------------------
当同一 IP 既是蜘蛛,又不是蜘蛛(即有时从某个搜索网站跳转过来,但有时直接输入你网站的网址)时,你的总量就比分量和小了。