select count(*) from emp
ORA-00942: table or view does not existMore Details: https://docs.oracle.com/error-help/db/ora-00942
create table emp
(department_id number primary key,
employee_email varchar2(4000))
Table created.
insert into emp values(10, 'richard.jones@gmail.com:elizabeth.phelps@gmail.com:christopher.taylor-johnson@outlook.com :steven.king@yahoo.com')
1 row(s) inserted.
insert into emp values(20, 'sylvia.plath@outlook.com:steven.king@yahoo.com:jack.g.london@mail.com:richard.jones@gmail.com :t.s.white@gmail.com:emily.temple-wood@yahoo.com:john.ruskin@rediff.com:jane.austen@gmail.com')
1 row(s) inserted.
insert into emp values(40, 'elizabeth.phelps@gmail.com:albert.camus@gmail.com:steven.king@yahoo.com:george.bernard.shaw@gmail.com: haruki.murakami@gmail.com:j.r.r.tolkien@rediffmail.com:frederick.douglass@gmail.com: ralph.waldo.emerson@mail.com:jane.austen@gmail.com:percy.bysshe.shelley@yahoo.com:richard.jones@gmail.com')
1 row(s) inserted.
insert into emp values(50, 'steven.king@yahoo.com')
1 row(s) inserted.
insert into emp values(60, 'steve.jones-smith@inbox.com:edgar.allan.poe@outlook.com:henry.david.thoreau@gmail.com:audrey.jameson-wright@gmail.com:jane.austen@gmail.com:sylvia.plath@outlook.com')
1 row(s) inserted.
select count(*) from emp
COUNT(*) | 5 |
---|
with t as
( select department_id, employee_email str
from emp
),
elements as (
select department_id, regexp_substr(replace(str,':',','),'[^,]+', 1, lev) AS elem
from t, lateral (
select level lev from dual
connect by regexp_substr(replace(str,':',','), '[^,]+', 1, level) is not null
)
)
select department_id, listagg(distinct elem,',') within group (order by elem) as tags
from elements
group by department_id
DEPARTMENT_ID | TAGS | 10 | christopher.taylor-johnson@outlook.com ,elizabeth.phelps@gmail.com,richard.jones@gmail.com,steven.king@yahoo.com | 20 | emily.temple-wood@yahoo.com,jack.g.london@mail.com,jane.austen@gmail.com,john.ruskin@rediff.com,richard.jones@gmail.com ,steven.king@yahoo.com,sylvia.plath@outlook.com,t.s.white@gmail.com | 40 | haruki.murakami@gmail.com, ralph.waldo.emerson@mail.com,albert.camus@gmail.com,elizabeth.phelps@gmail.com,frederick.douglass@gmail.com,george.bernard.shaw@gmail.com,j.r.r.tolkien@rediffmail.com,jane.austen@gmail.com,percy.bysshe.shelley@yahoo.com,richard.jones@gmail.com,steven.king@yahoo.com | 50 | steven.king@yahoo.com | 60 | audrey.jameson-wright@gmail.com,edgar.allan.poe@outlook.com,henry.david.thoreau@gmail.com,jane.austen@gmail.com,steve.jones-smith@inbox.com,sylvia.plath@outlook.com |
---|