Oracle sql function LISTAGG和字符替换 regexp_replace
select business_unit, voucher_id, listagg( vat_txn_type_cd, ',') within group (order by business_unit, voucher_id) from ps_voucher_line a
where business_unit = 'CZ090'
and voucher_id like '%656'
group by business_unit, voucher_id;
--把一列值转化为一行用逗号隔开。 但是要去掉重的值
SELECT BUSINESS_UNIT,
VOUCHER_ID,
LISTAGG (VAT_TXN_TYPE_CD, ',')
WITHIN GROUP (ORDER BY BUSINESS_UNIT, VOUCHER_ID)
FROM (SELECT DISTINCT BUSINESS_UNIT, VOUCHER_ID, VAT_TXN_TYPE_CD
FROM PS_VOUCHER_LINE)
WHERE business_unit = 'CZ090' AND voucher_id LIKE '%656'
GROUP BY BUSINESS_UNIT, VOUCHER_ID
listagg字符串拼接字符串过长问题解决用xmlagg方法
INSERT INTO PS_GM_DEPT_POS_HTM
SELECT SETID
,DEPTID
,xmlagg(xmlparse(content '<div class =''left''>'||DESCR||'</div><div class =''right''>'||MAX_HEAD_COUNT||'</div>' wellformed)
ORDER BY '<div class =''left''>'||DESCR||'</div><div class =''right''>'||MAX_HEAD_COUNT||'</div>').getclobval() ||'<div class=''one''></br></div>'
,' '
FROM PS_GM_DEPT_POS_NUM
GROUP BY SETID
,DEPTID;
regexp_replace(dbms_lob.substr('ssss'),'[^[:print:]]','')