帮忙看看
select CountIP,count(*) from Count_ReturnAndDepth where CustomerID=1 and
countTime between '2006-1-1 ' and '2009-5-12 ' and
countUrl in (select countUrl from Count_SuccessUrl where CustomerID=1)
group by countIP
问题:只有countURl在(select countUrl from Count_SuccessUrl where CustomerID=1)这里面才统计,我想countURl不在select countUrl from Count_SuccessUrl where CustomerID=1这里的也统计,数据为0,要怎么改写这个脚本,谢谢,想老半天没想出来!
------解决方案--------------------select CountIP,count(*)
from Count_ReturnAndDepth AS CR
LEFT JOIN (select countUrl from Count_SuccessUrl where CustomerID=1)CS
ON CR.countUrl = CS.countUrl
WHERE CustomerID=1 and
countTime between '2006-1-1 ' and '2009-5-12 '
group by countIP
------解决方案----------------------try
select CountIP,
case when countUrl in (select countUrl from Count_SuccessUrl where CustomerID=1) then count(*) else 0 end
from Count_ReturnAndDepth where CustomerID=1 and
countTime between '2006-1-1 ' and '2009-5-12 '
group by countIP