我怎么能只找到较少的计数值 Name Must want 3 groupName also

How can i found only the less count values Name Must want 3 groupName also

IN SQL (adventureWorks) 数据库...

I/P :
ALTER PROCEDURE spLessDep
AS
BEGIN
SELECT COUNT(Name) AS COUNT,max(GroupName)
FROM HumanResources.Department
WHERE GroupName <(SELECT MAX(GroupName) FROM HumanResources.Department)
GROUP BY GroupName
ORDER BY COUNT(Name)
END

EXEC spLessDep

O/P:

Name   GroupName

2      Inventory Management
2      Manufacturing
2      Quality Assurance
3      Research and Development
5      Executive General and Administration

要求:我希望列(名称)中的所有最小值由唯一语句

我认为你在描述 TOP (1) WITH TIES:

SELECT TOP (1) WITH TIES COUNT(Name) AS COUNT, GroupName
FROM HumanResources.Department
WHERE GroupName < (SELECT MAX(GroupName) FROM HumanResources.Department)
GROUP BY GroupName
ORDER BY COUNT(Name);