SQL Get Top 10 records by date

Posted by Pselus on Stack Overflow See other posts from Stack Overflow or by Pselus
Published on 2010-04-04T19:17:56Z Indexed on 2010/04/04 19:23 UTC
Read the original article Hit count: 415

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql