home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
moodle.waes.ac.uk
/
moodle.waes.ac.uk.zip
/
moodle.waes.ac.uk
/
TMG
/
SP1-TMG-KB981324-AMD64-ENU.msp
/
PCW_CAB_SHFx2
/
F2143_msfpcui.dll
/
BINARY
/
25594
< prev
next >
Wrap
Text File
|
2010-06-15
|
2KB
|
60 lines
CREATE PROCEDURE [dbo].[ISA_spUrlfUsersRDL]
@FromDate datetime,
@ToDate datetime,
@ReportType varchar(10),
@TopCount int
AS
BEGIN
DECLARE @SummTableName varchar(100)
SET @SummTableName = dbo.fnGetSummaryTableName('tblUrlfUserSummary', @FromDate, @ToDate, @ReportType)
CREATE TABLE #Table1
(
UserName nvarchar(514),
UrlfIncidents bigint
);
IF OBJECT_ID (@SummTableName, 'u') IS NOT NULL
BEGIN
DECLARE @strQuery varchar(8000)
SET @strQuery =
'SELECT
UserName,
SUM(UrlfIncidents) AS UrlfIncidents
FROM ' + @SummTableName + '
WHERE ([date] >= ' + QUOTENAME(CONVERT(varchar, @FromDate, 126),CHAR(39)) + ' AND [date] <= ' + QUOTENAME(CONVERT(varchar, @ToDate, 126),CHAR(39)) + ')
GROUP BY [UserName]
ORDER BY SUM(UrlfIncidents) DESC;
'
INSERT #Table1
EXEC(@strQuery)
END
CREATE TABLE #Table2
(
UserName nvarchar(514),
UrlfIncidents bigint
);
INSERT INTO #Table2
SELECT TOP(@TopCount)
UserName AS UserName,
UrlfIncidents AS UrlfIncidents
FROM #Table1
INSERT INTO #Table2
SELECT
N'{[23124]}' AS UserName,
SUM(UrlfIncidents) AS UrlfIncidents
FROM #Table1 t1
WHERE NOT EXISTS
(SELECT * FROM
(SELECT TOP(@TopCount) *
FROM #Table1) t2
WHERE t1.UserName = t2.UserName)
DECLARE @TotalUrlfIncidents bigint
SET @TotalUrlfIncidents = (SELECT SUM(UrlfIncidents) FROM #Table2)
IF (@TotalUrlfIncidents = 0)
SET @TotalUrlfIncidents = 1
SELECT
[dbo].[fnUserOrIpAddressToText]([UserName]) AS [UserName],
[UrlfIncidents] AS Requests,
(CAST([UrlfIncidents] AS decimal) / @TotalUrlfIncidents) AS RequestRatio
FROM #Table2
END