This is the current result that can be changed from day to day
(int) (nvarchar)
Number Grade
--------------
1 a
1 c
2 a
2 b
2 c
3 b
3 a
What I need help is to achieve this result below.
Number Grade
-----------------
1 a, c
2 a, b, c
3 b, a
Obviously you'll need to replace
dbo.tablename
with your actual table. Also I'm assuming you're using SQL Server 2005 or better - always useful to specify.In SQL Server 2017 and Azure SQL Database, you can use the new aggregation function
STRING_AGG()
, which is a lot tidier in this case:Use: