Reputation: 25
I'm currently trying to create a report using SQL Developer.
I have these 2 tables:
PERSONS (IDPerson, NamePerson)
PENALTIES (IDPenalty, DatePenalty, Description, IDPerson)
The tables are polulated.
How could I create a table like
using recursive queries in SQL? or it's there any other solution? Thank you in advance.
Upvotes: 0
Views: 42
Reputation:
select p.nameperson as name, p.idperson as id,
listagg(to_date(x.datepenalty, 'dd/mm/yyyy') || ' - ' || x.description, '; ')
within group (order by x.datepenalty) as penalties
from persons p left outer join penalties x
on p.idperson = x.idperson
group by p.idperson;
(Not tested - you didn't provide test data.)
Upvotes: 2