gpt4 book ai didi

sql - Group By 子句中的别名 - 标识符无效

转载 作者:行者123 更新时间:2023-12-02 09:10:06 26 4
gpt4 key购买 nike

我尝试了很多方法,但无法解决这个问题......

我正在执行 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;

ERROR at line 4: ORA-00904: "AGE": invalid identifier

有什么想法吗?

最佳答案

不要在您的组中添加别名:

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com