select c.id, c.fname, c.lname, d.phoneList
from customers c
left outer join
(
select listagg(telNo, ',') within group (order by telNo) as phoneList
from customerPhones
group by p.telNo
) d
on (c.id = d.id)
On the above query, i am getting the following error on the statement c.id = d.id
ORA-00904 "d.id" invalid identifier.
It only works if i include it in the select statement and meaning that need to include it in the group by statement. Is there any way i can use d.id without having to include it in the group by statement?
just simplify to this?