如果我有一个包含两列的表格,例如名称和ID,其中ID是GUID,如何从第2列返回最多发生的Guid值?
答案 0 :(得分:4)
未测试:
SELECT TOP 1 ID, COUNT(*) AS CountOfRows
FROM UnknownTable
GROUP BY ID
ORDER BY CountOfRows DESC
答案 1 :(得分:3)
SELECT TOP 1 ID, COUNT(ID) AS count
FROM IDTable
GROUP BY ID
ORDER BY count DESC