SQL Get Top 10 records by date
- by Pselus
I have a table full of bugs. The BugTitle is the page erroring and I also capture the error line.
I would like to build an SQL Query that selects the top 10 bugs based on bugtitle and error line.
I have this query:
SELECT COUNT(BugTitle) AS BugCount, BugTitle, ErrLine
FROM Bugs
WHERE BugDate >= DateAdd(Day, -30, DateDiff(Day, 0, GetDate()))
GROUP BY BugTitle, ErrLine
ORDER BY BugCount, ErrLine DESC
But I'm not sure if it's correct. I'm pretty sure that my test data only has 1 bug that happens on the same line but that's not showing up with this query.
Can anyone help?