ALTER PROCEDURE [dbo]. [Usp_visit_detail]
(@siteid BIGINT,
@Startime VARCHAR (),
@Endtime VARCHAR (),
@Aflag INT = 10,--initial value of 10, not 10, indicates an incoming parameter
@Area VARCHAR = ' n ',----an initial value of n, not n, indicates an incoming parameter
@Nflag INT = 10,-The initial value is 10, not 10, it indicates an incoming parameter
@VALUE1 varchar = ' n '--initial value n, not n, indicates an incoming parameter
)
as
BEGIN
DECLARE @AFlag0 varchar (),
@NFlag0 varchar (),
[email protected] varchar,
@Sqlstr varchar (+)
IF @AFlag = ten
SET @AFlag0 = ' '
ELSE
SET @AFlag0 = ' and aflag= ' + CAST (@AFlag as VARCHAR)
IF @Area = ' N '
SET @Area = ' '
ELSE
SET @Area = ' and province= ' + ' + ' + @Area + '
IF @NFlag = ten
SET @NFlag0 = ' '
ELSE
SET @NFlag0 = ' and nflag= ' + CAST (@NFlag as VARCHAR)
IF @Value1 = ' N '
SET @Value1 = ' '
ELSE
SET @Value1 = ' and value1= ' + ' + ' + @Value1 + '
SET @Sqlstr = ' SELECT a.intime, C.visitornm, C.vcount, (case is a.value2 = ' + ' + ' + ' + ' + ' + ' then a.value1 + ' + ') ' + ' + ' when a.value2 = ' + ' + ' + ' + ' then a.value1 + ' + ' + ' + ' + ' + ' + ' + a.value2 END ' as Source0,
DATEDIFF (Ms,a.intime, A.outtime) as Vtime, A.pages, A.REV1, dbo. Get_url (A.siteid, A.inurlid) as Inrul, dbo. Get_url (A.siteid, a.outurlid) as Outrul
From dbo. f_pages_t as a INNER JOIN (SELECT VisitorID, MAX (ID) as ID from dbo. f_pages_t WHERE SiteID = ' + ' +convert (VARCHAR, @siteid) + ' + ' and day0>= ' [email protected]+ ' and day0<= ' [email Protected][email protected]
[email protected]+ @Nflag0 + @Value1 + ' GROUP by VisitorID) As B on a.id = b.ID left OUTER JOIN dbo. F_visit as C on a.visitorid = C.visitorid '
PRINT @sqlstr
EXEC (@sqlstr)
END