gpt4 book ai didi

SQL Oracle ORA-00904 : invalid indentifier error

转载 作者:行者123 更新时间:2023-12-04 18:22:29 24 4
gpt4 key购买 nike

谁能帮我查明为什么这段代码返回 SQL Oracle ORA-00904: invalid indentifier 错误?该查询在没有 Country = 'Argentina' 的情况下有效,但我需要按此值进行过滤。谁能指出我正确的方向?

select llattrdata.ID dataid,

max(case when llattrdata.ATTRID = 4 then llattrdata.VALSTR end) Country

from llattrdata, dtree

where
llattrdata.DEFID = 19400074 and
llattrdata.VERNUM = dtree.VERSIONNUM and
llattrdata.ID = dtree.DATAID and
Country = 'Argentina'
group by llattrdata.ID

最佳答案

当您对分组条件进行过滤时,您需要使用 having而不是 where .

它应该是这样的:

select llattrdata.ID dataid,
max(case when llattrdata.ATTRID = 4 then llattrdata.VALSTR end) Country
from llattrdata, dtree
where llattrdata.DEFID = 19400074
and llattrdata.VERNUM = dtree.VERSIONNUM
and llattrdata.ID = dtree.DATAID
group by llattrdata.ID
having max(case when llattrdata.ATTRID = 4 then llattrdata.VALSTR end) = 'Argentina'

关于SQL Oracle ORA-00904 : invalid indentifier error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10386200/

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