having分组还有更高端的用法,如下:
--查询所有雇员的最大开户数
SELECT
open_emp_id,
COUNT(*) how_many
FROM
account
GROUP BY
open_emp_id
HAVING
COUNT(*) = (
SELECT
MAX(emp_cnt.how_many)
FROM
(
SELECT
COUNT(*) how_many
FROM
account
GROUP BY
open_emp_id
) emp_cnt
);