_____________
l A l B l
l 10 l CLARK l
l 10 l KING l
l 10 l MILLER l
l 20 l JONES l
l 20 l FORD l
l 20 l ADAMS l
l 20 l SCOTT l
l 30 l ALLEN l
l 30 l JAMES l
l 30 l TURNER l
l 30 l MARTIN l
l 30 l BLAKE l
l 30 l WARD l
l____l________ l
ต้องการให้ได้ ข้อมูลแบบนี้
______________________________________________________
l 10 l CLARK l KING l MILLER l l l
l 20 l ADAMS l FORD l JONES,SCOTT l l l
l 30 l ALLEN l BLAKE l JAMES,MARTIN l TURNER l WARD l
l___ l________ l_______ l_______________l_________l________l
Select CustomerID,
Substring(
(Select ', '+ OrderID From CustomerOrder B Where
B.CustomerID = A.CustomerID For XML Path('')),2,8000)
As AllOrderID
From Customer A
GROUP_CONCAT ของ SQL Server ครับ ไม่ทราบว่าท่านใดเคย
SELECT m.maskid, m.maskname, m.schoolid, s.schoolname, maskdetail = STUFF((
SELECT ',' + md.maskdetail
FROM dbo.maskdetails md
WHERE m.maskid = md.maskid
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '')
FROM dbo.tblmask m
JOIN dbo.school s ON s.ID = m.schoolid
ORDER BY m.maskname