Can anybody help me pinpoint why this code is returning an SQL Oracle ORA-00904: invalid indentifier error? The query works without the Country = ‘Argentina’, but I need to filter down by this value. Can anyone point me in the right direction?
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
When you are filtering on grouped conditions, you need to use
havinginstead ofwhere.It should be something like: