tags:

views:

42

answers:

1

I asked a question earlier today here. However, what I neglected to check with that question is how can I get AN id of those bug records? So for example, if I have a bug that has happened 3 times, how can I return one of the ID's from those 3 records?

+2  A: 

You could return either the Max or Min Bug Id

SELECT TOP(10) COUNT([BugTitle]) AS 'BugCount', [BugTitle], [ErrLine], MIN([BugId]) AS 'BugId'
FROM [Bugs] 
WHERE [BugDate] >= DateAdd(Day, -30, DateDiff(Day, 0, GetDate())) 
GROUP BY [BugTitle], [ErrLine]
ORDER BY COUNT([BugTitle]) DESC 
Kane