我試圖選擇max(行數)。 這裏是我的2個SELECTSQL嵌套聚合函數MAX(COUNT(*))
SELECT MAX(COUNT_OF_ENROLEES_BY_SPEC) FROM
(SELECT D.SPECCODE, COUNT(D.ENROLEECODE) AS COUNT_OF_ENROLEES_BY_SPEC
FROM DECLARER D
GROUP BY D.SPECCODE
);
SELECT S.NAME, MAX(D.ENROLEECODE)
FROM SPECIALIZATION S
CROSS JOIN DECLARER D WHERE S.SPECCODE = D.SPECCODE
GROUP BY S.NAME
HAVING MAX(D.ENROLEECODE) =
(SELECT MAX(COUNT_OF_ENROLEES_BY_SPEC) FROM
(SELECT D.SPECCODE, COUNT(D.ENROLEECODE) AS COUNT_OF_ENROLEES_BY_SPEC
FROM DECLARER D
GROUP BY D.SPECCODE
)
);
第一個是工作正常的變種,但我想在我的第二個變體使用「具有」重寫它像,並添加有一個多列。但是現在第二個變體不會在結果中輸出任何數據,只是空列。 我該如何解決它?謝謝)
你想要最大代碼等於最大*數*代碼?這看起來不合理。 –
我想統計專業代碼分組的行數(聲明),而不是採用最流行的專業化。對不起,我的英文;(現在清楚了嗎?) – skymk