I have a report that i imported into access and need a query that displays the top 25% of users based on their usage which is times run. I then these users average duration based on their (total duration/times run) and then divided by 60 so i can get the total hours.
Providing me the SQL would be helpful since i am learning this coding and obtaining concrete examples help.
Attached is spreadsheet that provides the data and output i require. Dragon1.xls
Microsoft Access
Last Comment
Mez4343
8/22/2022 - Mon
Norie
I don't quite understand the result.
User35 has run 78 times not 350, and User4 has run 224 times not 369.
what code do i need to add to remove all users whose usage field is null before calculating the top 25%
Mez4343
ok, great.
<<what code do i need to add to remove all users whose usage field is null before calculating the top 25%>>
I would add a WHERE clause to filter out users that you do not want to be part of the SUM() function rather than trying to filter NULL from the final result. Like this but modify the WHERE clause as needed.
SELECT TOP 25 PERCENT [Last User], SUM([Total Duration] / [Times Run] / 60) as 'Average Duration'
FROM Table1
WHERE [TotalDuration] > 0 AND [Times Run] > 0
GROUP BY [Last User]
User35 has run 78 times not 350, and User4 has run 224 times not 369.