wasabi3689
asked on
how to output how many time each report run?
I have the following query
SELECT max([Name])
--,[Path]
--,[TimeStart]
--,[TimeEnd]
--,[UserName]
--,[day#]
--,Created_Date
,COUNT(Name)
FROM [AnalysisReport].[dbo].[SS RSReportRu nTime]
GROUP BY NAME
I have to have the result - how many count each report run total with one time each time cpount although maybe a report may run more than once a day
SELECT max([Name])
--,[Path]
--,[TimeStart]
--,[TimeEnd]
--,[UserName]
--,[day#]
--,Created_Date
,COUNT(Name)
FROM [AnalysisReport].[dbo].[SS
GROUP BY NAME
I have to have the result - how many count each report run total with one time each time cpount although maybe a report may run more than once a day
What do you want the output 'report' to look like?
»bp
»bp
ASKER
each report may run by an user more than once in a day. If more than once, there will be two rows in a day. But I only want the latest run and count one only no matter how many entries in a day for a report run. That is why I put max function. So far my query listed captures all the run counts in a day. How to fix it?
Wouldn't you then want
SELECT [Name]
,MAX(Created_Date)
,COUNT(Name)
FROM [AnalysisReport].[dbo].[SSRSReportRunTime]
GROUP BY NAME
Since you stated you always want a COUNT of 1 for the latest date, then perhaps you are looking for:
»bp
SELECT Name, MAX(Created_Date) Date, 1 Count
FROM SSRSReportRunTime
GROUP BY NAME;
»bp
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
If grouping by name, why do you have max( name )?
Isn't the correct query
select
name
, count( * )
from tablename
group by
name
;
Regards
David