set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
-- ================================== ===========
-- Author:wgh
-- Create date: 2012-06-07
-- Description: IP access pre-statistics
-- ====== =======================================
CREATE PROCEDURE [dbo].[PROC_HB_PreStatByIP]
@BeginTime varchar(50),
@EndTime varchar(50),
@TimeType int, --0 represents hours, 1 represents days
@ChannelID varchar(10)='0',
@I pAddress varchar(20)
AS
BEGIN
declare @sql1 nvarchar(2000)
IF @TimeType = 0
BEGIN
SET @sql1='SELECT CONVERT(varchar(13),AddTime ,120) AS ' 'Date''
,ChannelID AS ''Promotion channel''
,IPAddress AS ''IP address''
,ViewCount AS ''Number of views''
,ClickCount AS ''Number of clicks''
FROM dbo.HB_AdPreStatIP WHERE AddTime>='''+@BeginTime+''' AND AddTime<='''+@EndTIme+'''
sql1 =@sql1 + ' AND ChannelID='''+@ChannelID+''''
1 +' AND IPAddress=' ''+@IpAddress+''''
END
SET @sql1 =@sql1+' ORDER BY ViewCount DESC' END
'SELECT CONVERT(varchar(10), AddTime,120) AS ''Date''
,ChannelID AS ''Promotion channel''
,IPAddress AS ''IP address''
, , SUM(ViewCount) AS , SUM (ViewCount) (ClickCount) AS ''Number of clicks''
‐ ‐ ‐ ‐ ‑ ‑ ‐ ‐ dbo.HB_AdPreStatIP WHERE '0'
sql1 =@sql1 +' AND IPAddress='''+@IpAddress+'''' ENDSET @sql1 =@sql1 + 'GROUP BY CONVERT(varchar(10),AddTime,120),ChannelID,IPAddress ORDER BY SUM(ViewCount) DESC' END EXEC sp_executesql @sql1 END