Oracle一列的多行数据合并拼成一行显示

需求:一个患者的病例存在多处规则不符

合并成

解决:

1.wm_concat方法:

select data_id,wmsys.wm_concat(rule_name) as rule_name
from RHSA_AUDIT_RESULTS where data_id='a3506a2206f3417fb204993096d5ae7a'
group by data_id 

2.listagg方法:

SELECT data_id, listagg(to_char(rule_name), ';') within group(ORDER BY data_id) AS rule_name
  FROM RHSA_AUDIT_RESULTS T  where data_id='a3506a2206f3417fb204993096d5ae7a' GROUP BY data_id

 

你可能感兴趣的:(Oracle一列的多行数据合并拼成一行显示)