Sqlserver
 sql >> Base de Dados >  >> RDS >> Sqlserver

posso usar pivô para isso?

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