I have to comma separate all the values of a column and for this i am using LISTAGG function, but getting error
"ORA-00923: FROM keyword not found where expected"
Please find below code i am using. Kindly suggest why i am getting this error.
select listagg(t.user_email, ', ') WITHIN GROUP (ORDER BY t.user_email) AS DelimitedEmail
FROM (
SELECT user_email
, sum(LENGTH(user_email)) OVER (ORDER BY user_email) R1
, row_number() over (order by user_email) rn
from tbl_Users
) t
WHERE t.R1 <= 4000;