This question already has answers here:
SQL - using alias in Group By

(10个答案)


2年前关闭。




我用很多方法尝试了很多次,但是我无法解决...

我正在执行Oracle SQL查询:
SELECT
    TRUNC(months_between(sysdate, DateofBirth) / 12) AS "age"
FROM players
group by age
HAVING COUNT
    (TRUNC(months_between(sysdate, DateofBirth) / 12)) > 30;



有任何想法吗?

最佳答案



https://stackoverflow.com/a/3841804/6358346

正确的方法:

SELECT TRUNC(months_between(sysdate, DateofBirth) / 12) AS "age"
FROM players
GROUP BY TRUNC(months_between(sysdate, DateofBirth) / 12)
HAVING COUNT(TRUNC(months_between(sysdate, DateofBirth) / 12)) > 30;

关于sql - Group By子句中的别名-无效标识符,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53402397/

10-12 18:00