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
2009-04-27 05:13:27
+4
A:
Untested:
SELECT TOP 1 ID, COUNT(*) AS CountOfRows
FROM UnknownTable
GROUP BY ID
ORDER BY CountOfRows DESC
JeremyDWill
2009-04-27 05:15:36