答案 0 :(得分:0)
这将有效:
SELECT UCSM, OS_NAME, COUNT(*)
FROM TABLE
GROUP BY OS_NAME, UCSM
答案 1 :(得分:0)
其中任何一个都可行。第二个更好,但第一个会告诉你如何在分组时不是那么直接(或可实现),你可以如何做到这一点。
SELECT
ISNULL(SUM(CASE WHEN OS_NAME = 'Linux' THEN 1 ELSE 0 END), 0) AS [Linux Servers],
ISNULL(SUM(CASE WHEN OS_NAME = 'Windows' THEN 1 ELSE 0 END), 0) AS [Windows Servers]
FROM YourTable
SELECT OS_NAME, COUNT(*)
FROM YourTable
GROUP BY OS_NAME