oracle 多条查询记录 结果连接成以逗号分割字符串
--查询
select wmsys.wm_concat(province_no) province_no from P_PROVINCE_FUNCTION where province_id='201';
--更新
update P_PROVINCE_ATTRIBUTION a set NOS=(select wmsys.wm_concat(province_no) province_no from P_PROVINCE_FUNCTION f where f.province_id=a.province_id);
--查询并排序
SELECT T.province_id,MAX(T.province_nos) AS province_nos FROM (SELECT province_id,
WMSYS.WM_CONCAT(province_no) OVER(PARTITION BY province_id ORDER BY province_no asc) province_nos,
row_number() over(PARTITION BY province_id ORDER BY province_no asc) rs
from P_PROVINCE_FUNCTION ) T where T.province_id='201'
GROUP BY T.province_id
--更新并排序
update P_PROVINCE_ATTRIBUTION a set a.NOS=
(
SELECT MAX(T.province_nos) AS province_nos FROM (SELECT province_id,
WMSYS.WM_CONCAT(province_no) OVER(PARTITION BY province_id ORDER BY province_no asc) province_nos,
row_number() over(PARTITION BY province_id ORDER BY province_no asc) rs
from P_PROVINCE_FUNCTION ) T where T.province_id=a.province_id
GROUP BY T.province_id
);