0
votes

have this error even though table present

select count(eventguest.memberid) + x as total, eventid
from (
    select count(eventmember.memberid) as X, eventmember.eventid
    from eventmember
    group by eventid
)
inner join eventguest on eventmember.eventid = eventguest.eventid
group by eventid

ORA-00904: "EVENTMEMBER"."EVENTID": invalid identifier 00904. 00000 - "%s: invalid identifier" *Cause:
*Action: Error at Line: 16 Column: 15

1
This is because eventmember.eventid is not accessible out side of the subquery in from clause. You need to make an alias to the query and use <alias>.eventid. - Sandesh
This query does not look useful. I would suggest that you ask a new question with sample data, desired results, and the logic you want to implement. - Gordon Linoff
Please don't tag with MySQL if you are using Oracle. - Mark Rotteveel

1 Answers

0
votes

Following query should work correctly:

SELECT Count(eventguest.memberid) + x AS total, 
    Y.eventid 
FROM   
(
 SELECT Count(eventmember.memberid) AS X, 
       eventmember.eventid 
 FROM   eventmember 
 GROUP  BY eventid
) Y
INNER JOIN eventguest 
ON Y.eventid = eventguest.eventid 
GROUP  BY Y.eventid