递归记录oracle
Recursive records oracle
我目前正在尝试使用 SQL Developer 创建报告。
我有这 2 tables:
PERSONS (IDPerson, NamePerson)
PENALTIES (IDPenalty, DatePenalty, Description, IDPerson)
table 被填充。
我怎样才能创建一个table喜欢
在SQL中使用递归查询?或者还有其他解决方案吗?
提前谢谢你。
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;
(未测试 - 您未提供测试数据。)
我目前正在尝试使用 SQL Developer 创建报告。
我有这 2 tables:
PERSONS (IDPerson, NamePerson)
PENALTIES (IDPenalty, DatePenalty, Description, IDPerson)
table 被填充。
我怎样才能创建一个table喜欢
在SQL中使用递归查询?或者还有其他解决方案吗? 提前谢谢你。
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;
(未测试 - 您未提供测试数据。)