tom_optimum
asked on
SQL Query - List most used report
Hi all,
I have a table structure like this:
ReportLogID, UserID, ReportID, ReportName, Viewed
The table stores which users have run which reports in our system.
I would like to run a SQL query that lists the reports (grouped by ReportID) and shows me and the number of times it has been run.
I would also like to choose the start and end date that I want to run the query for (this is the Viewed field).
I can do this in Crystal Reports (where I am comfortable!), but I am not sure what to do in SQL.
Any hep would be great.
Thanks,
Tom
I have a table structure like this:
ReportLogID, UserID, ReportID, ReportName, Viewed
The table stores which users have run which reports in our system.
I would like to run a SQL query that lists the reports (grouped by ReportID) and shows me and the number of times it has been run.
I would also like to choose the start and end date that I want to run the query for (this is the Viewed field).
I can do this in Crystal Reports (where I am comfortable!), but I am not sure what to do in SQL.
Any hep would be great.
Thanks,
Tom
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great - thanks.
So, I am using this:
Thanks,
Tom
So, I am using this:
SELECT ReportID, ReportName, count(*), min(Viewed), max(Viewed)
FROM tblReportViewLog
GROUP BY ReportID, ReportName
What would I need to do so I can type in the start and end date instead of min and max?Thanks,
Tom
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Great - thanks.
Here is what I used int he end
Tom
Here is what I used int he end
-- Reports run over all time
SELECT ReportID, ReportName, count(*), min(Viewed), max(Viewed)
FROM tblReportViewLog
GROUP BY ReportID, ReportName
-- Reports run between two dates
SELECT ReportID, ReportName, Count(ReportID) Counts FROM tblReportViewLog
WHERE Viewed BETWEEN '2013-09-01' AND '2014-07-29'
GROUP BY ReportID, ReportName
Thanks for you help.Tom
ASKER
Great help guys.
Thanks,
Tom
Thanks,
Tom
The below query will let you know that which report run how many times.
Open in new window