vinnydrums
Starting Member
1 Post |
Posted - 2013-10-21 : 02:34:51
|
I have managed to create a Cascading parameters report with 4 input parameters as below.I'm unable to create a Summary dataset with stats. PLease help me.Parameter 1: @DivisionParameter 2: @DatasetnameParameter 3: @StartTimeParameter 4: @EndTimeDataset 1:Select * from Monitoring..VelocityDatasetCategoryDataset 2:Select Distinct DatasetName,DatasetID,divisionID from Monitoring..VelocityDataset nolock order by DatasetNameDataset 3:SELECT A.DatasetID, A.DatasetName, A.BatchNumber, A.BatchStartTime, A.BatchEndTime, A.Runtime, A.DeltaCount, A.DeltaSizeInMB,A.StatusIDFROM Monitoring..VelocityDatasetSLASummary AS A INNER JOINMonitoring..VelocityDataset AS B ON A.DatasetName = B.DatasetALiasWHERE (A.BatchStartTime >= @BatchStartTime) AND (A.BatchEndTime <= CONVERT(date, DATEADD(dd, 1, @BatchEndTime), 101))ORDER BY A.BatchNumber DESCDataset 4: This is where I'm having issue.IF OBJECT_ID('TEMPDB..#SummaryTable')IS NOT NULL DROP TABLE #SummaryTableCREATE TABLE #SummaryTable (DatasetName sysname, DatasetID INT,BatchStartTime datetime,BatchEndTime datetime,StatusID INT,IsScheduled INT)Insert INTO #SummaryTableSelect A.DatasetName,A.DatasetID,A.BatchStartTime,A.BatchEndTime,A.StatusID,B.IsScheduled FROM Monitoring..VelocityDatasetSLASummary A (NOLOCK)INNER JOIN Monitoring..VelocityDataset B ON A.DatasetName = B.DatasetALias WHERE (A.BatchStartTime >= @BatchStartTime) AND (A.BatchEndTime <= CONVERT(date, DATEADD(dd, 1, @BatchEndTime), 101))--and B.DatasetID = 21IF (Select top 1 IsScheduled FROM #SummaryTable) = 0 BEGIN IF OBJECT_ID('TEMPDB..#Scheduled')IS NOT NULL DROP TABLE #Scheduled CREATE TABLE #Scheduled ([Status] Varchar(20),[BatchCount] Float,DatasetID INT) Insert INTO #Scheduled SELECT 'Total Count' as [Status], COUNT(1), (Select top 1 DatasetID from #SummaryTable) from #SummaryTable UNION ALL Select 'Success Count' as [Status],COUNT(1),(Select top 1 DatasetID from #SummaryTable) from #SummaryTable where statusID = 1 Union All Select 'Failure Count' as [Status],COUNT(1),(Select top 1 DatasetID from #SummaryTable) from #SummaryTable where statusID = 2 Union All Select 'Late Start' as [Status], COUNT(1),(Select top 1 DatasetID from #SummaryTable) from #SummaryTable where statusID = 4 Union ALL Select 'OUT OF CYCLE (N/A)' as [Status],0,(Select top 1 DatasetID from #SummaryTable) Union ALL SELECT 'Total Expected' as [Status], COUNT(1),(Select top 1 DatasetID from #SummaryTable) from #SummaryTable Union all Select 'NO SHOW (N/A)' as [Status],0,(Select top 1 DatasetID from #SummaryTable) Select * from #Scheduled Union All Select 'Success Percentage' as [Status], 100 - (Cast((((Select [BatchCount] from #Scheduled where Status = 'Failure Count') + (Select [BatchCount] from #Scheduled where Status = 'Late Start'))/(Select [BatchCount] from #Scheduled where Status = 'Total Count')) as decimal(10,2))* 100 ),(Select top 1 DatasetID from #SummaryTable) Union all Select 'Overall Success Percentage' as [Status], 100 - (Cast((((Select [BatchCount] from #Scheduled where Status = 'Failure Count') + (Select [BatchCount] from #Scheduled where Status = 'Late Start'))/(Select [BatchCount] from #Scheduled where Status = 'Total Expected')) as decimal(10,2))* 100 ),(Select top 1 DatasetID from #SummaryTable) ENDELSE BEGIN PRINT N'Once above Non- schdeduled Query is sucessful, I shall start building for Scheduled datasets.' ENDEnd result of Dataset 4 should look like thisStatus BatchCount DatasetIDTotal Count 34 21Success Count 21 21Failure Count 12 21Late Start 1 21OUT OF CYCLE (N/A) 0 21Total Expected 34 21NO SHOW (N/A) 0 21Success Percentage 62 21Overall Success Percentage 62 21 |
|