Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

posso usare pivot per questo?

SELECT empRef_ID , mkt_route_ID=  
    STUFF((SELECT '/ ' + cast(mkt_route_ID as varchar)
           FROM table_2 b 
           WHERE b.sl_No = a.sl_No 
          FOR XML PATH('')), 1, 2, ''),sl_No 
FROM table_2 a
GROUP BY empRef_ID,sl_No