sql >> Database >  >> RDS >> Sqlserver

Door komma's gescheiden waarden met SQL Query

probeer dit:

SELECT City_Code, 
      Post_Code = 
        STUFF((SELECT ', ' + Post_Code
           FROM your_table b 
           WHERE b.City_Code = a.City_Code 
          FOR XML PATH('')), 1, 2, ''),
      Post_Code_Description=
        STUFF((SELECT ', ' + Post_Code_Description
           FROM your_table b 
           WHERE b.City_Code = a.City_Code 
          FOR XML PATH('')), 1, 2, '')
FROM your_table a
GROUP BY City_Code


  1. Hoe SCHEMA_NAME() werkt in SQL Server

  2. Barman Cloud – Deel 1:WAL Archief

  3. Vergelijkingsprobleem met Oracle PL/SQL-tekenreeksen

  4. Stop met SQL Server je vuile werk te laten doen