再次求助(实在没分了)
http://community.csdn.net/Expert/topic/5338/5338898.xml?temp=.8350183
------解决方案--------------------ALTER proc [dbo].[Depth]
as
begin
Update Count_ReturnAndDepth set StatisticsDepthOrFalse=2
where StatisticsDepthOrFalse=0
update a set DepthCount =DepthCount + b.sl --更新已存在的数量
from Count_DepthInformation a
join
(
select CustomerID,CountIp,CONVERT(CHAR(13), CountTime, 120 )+ ':00:00 ' as dt ,count(CountUrl) as sl
from Count_ReturnAndDepth
where StatisticsDepthOrFalse = 2
group by CustomerID,CountIp,CONVERT(CHAR(13), CountTime, 120 )+ ':00:00 '
) b on a.CountIp =b.CountIp and a.CustomerID =b.CustomerID and a. =b.dt
insert into Count_DepthInformation (CustomerID,CountIp,DepthCount,PostTime) --插入新的统计
select CustomerID,CountIp,dt ,sl
from
(
select CustomerID,CountIp,CONVERT(CHAR(13), CountTime, 120 )+ ':00:00 ' as dt ,count(CountUrl) as sl
from Count_ReturnAndDepth
where StatisticsDepthOrFalse = 2
group by CustomerID,CountIp,CONVERT(CHAR(13), CountTime, 120 )+ ':00:00 '
) b
where not exists (select 1 from Count_DepthInformation where b.CustomerID =CustomerID and b.CountIp = CountIp and PostTime =dt )
Update Count_ReturnAndDepth set StatisticsDepthOrFalse=1
where StatisticsDepthOrFalse=2
end
-----
改这个试试