https://www.youtube.com/watch?v=FtAhicbKqMw

https://www.nowcoder.com/feed/main/detail/592c5061c3214b648cc0f74ef6a91994

image.png

WHERE 与 HAVING 的根本区别在于:

SELECT col1, sum(col2)
FROM t
WHERE condition
GROUP BY col1
HAVING condition;