--listagg(合并多行的值为字符串,只用一列来显示)
select status, count(*), listagg(risk_id, ',') within group (order by risk_id) from rp_risk group by status;
select risk_id, status, listagg(risk_id, ',') within group (order by risk_id) over(partition by status) from rp_risk;
select risk.risk_id, listagg(officer.last_name || ',' || officer.first_name, '; ') within group(order by null) from rp_risk risk, rp_risk_area_ref re, rp_risk_area area, rp_risk_officer officer
where risk.risk_id = re.risk_id
and re.risk_area_id = area.risk_area_id(+)
and area.risk_officer_id = officer.risk_officer_id(+)
group by risk.risk_id;
--pivot(行专列,将多行的值改为多列显示)(for in的那个column,是某个列的值,也就是将某个列的值作为新的列的column,这个column下边的值好像只能来自一列)
select * from
(select risk.risk_id, re.risk_area_order, officer.last_name || ',' || officer.first_n