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

求一个 sql
一一个页面的统计表(tongji)中有

字段
url count createtime
index.aspx 1 xxxxxxx
1.aspx 1 xxxxxxx
2.aspx 1 xxxxxxx
. . .
. . .
. . .


现在要一次性取得   相应的页面   日访问量,月访问量,和总访问量




------解决方案--------------------
select url,ISNULL(a.[日访问量],0),ISNULL(a.[月访问量],0),ISNULL(a.[总访问量],0) from tburl
left join (
select url,
[日访问量] = case when datediff(d,createtime,getdate()) =0 then [count] else 0 end,
[月访问量] = case when datediff(m,createtime,getdate()) =0 then [count] else 0 end,
[总访问量] = [count]
from tongji) a
on a.url = tburl.url