知识日志2
知识提纲:
ORACLE合并列语法
wmsys.wm_concat(EmployeeName) --->wmsys.wm_concat()的使用(ORACLE语法)
select PASSWORD,to_char(wmsys.wm_concat(EmployeeName)) as aaa
from "000".tbEmployee where EmployeeCode in ('0000','0053482') group by PASSWORD;
初始数据:
password EmployeeName
123 陈伟1
123 陈伟2
执行上述SQL:
Password aaa
123 陈伟1,陈伟2
SQL 语法中对应的函数是:Stuff
SELECT id,
value = stuff
((SELECT ',' + value
FROM tb AS t
WHERE t .id = tb.id FOR xml path('')), 1, 1, '')
FROM tb
GROUP BY id