I have the following table:
My task is: for each event selected item , report the event id along with the total unit count for all items for that event.
I tried the following:
SELECT S.ITEMNO,S.EVENTID, S.ROOMID, T.TOTAL
FROM SELECTEDITEM S JOIN
(SELECT EVENTID, SUM(UNIT_COUNT) AS TOTAL
FROM SELECTEDITEM
GROUP BY EVENTID) AS T
ON S.ITEMNO=T.ITEMNO;
---------+---------+---------+---------+---------+---------+---------+---------
DSNT408I SQLCODE = -206, ERROR: T.ITEMNO IS NOT VALID IN THE CONTEXT WHERE IT
IS USED
Why is it not working? Can I join an existing table with one that has been just generated?