关于字段别名的问题
为啥将select后的字段起上别名后,HAVING中即能直接使用字段,也能使用别名,而where后面就不行呢?例:SELECT AVG(salary) a,department_id
FROM employees
GROUP BY department_id
HAVING AVG(salary)>1000;
SELECT AVG(salary) a,department_id
FROM employees
GROUP BY department_id
HAVING a>1000;
两者都行
SELECT employee_id i,salary FROM employees
WHERE i>10;
这样的就不行