Having和Where都是过滤数据的关键子句
Where是在分组之前过滤数据
SELECT * FROM Employees WHERE department = 'Tech';
Having是在分组之后利用聚合函数进行过滤
SELECT department, AVG(salary) AS average_salary
FROM Employees
GROUP BY department
HAVING AVG(salary) > 3000;
这就是Where和Having的区别