set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- ================================== ===========
-- Author:wgh
-- Create date: 2012-06-07
-- Description: IP存取預統計
-- ====== =======================================
CREATE PROCEDURE [dbo].[PROC_HB_PreStatByIP]
@BeginTime varchar(50),
@EndTime varchar(50),
@遠'0',
@IpAddress varchar(20)
AS
BEGIN
declare @sql1 nvarchar(2000)
(13),AddTime,120) AS ' '日期''
,ChannelID AS ''推廣管道''
,ViewCount AS ''瀏覽次數''
FROM dbo.HB_AdPreStatIP WHERE AddTime>='''+@BeginTime+''' AND AddTime
SET @sql1 = @sql1 + ' AND ChannelID='''+@ChannelID+''''
END
IF SET @sql1 =@sql1 +' AND IPAddress='''+@ IpAddress+''''
END
SET @sql1 =@sql1+' BEGIN
SET @sql1='SELECT CONVERT(varchar(10),AddTime,120) AS ''日期''
,ChannelID ,IPAddress AS ''IP位址''
,SUM(ClickCount) AS ''點選次數''
FROM dbo.HB_AdPreStatIP WHERE AddTime IF @ChannelID > '0'
BEGIN
SET @sql1 =@sql1 + ' AND ChannelID='''+@ChannelID+''''
BEGIN SET @sql1 =@sql1 +' AND IPAddress='''+@IpAddress+'''' ENDSET @sql1 =@sql1 + 'GROUP BY CONVERT(varchar(10),AddTime,120),ChannelChannelID,IP END EXEC sp_executesql @sql1 END