tags:

views:

283

answers:

2

If I have a table with two columns, e.g. Name, and ID, where ID is GUID's, how do I return the Guid value from Column 2 that occurs the most?

+3  A: 
SELECT TOP 1 ID, COUNT(ID) AS count
FROM IDTable
GROUP BY ID
ORDER BY count DESC
John Rasch
+4  A: 

Untested:

SELECT TOP 1 ID, COUNT(*) AS CountOfRows
FROM UnknownTable
GROUP BY ID
ORDER BY CountOfRows DESC
JeremyDWill