I am using SQL Server 2017 and I am trying to create a query that concatenates the languages and Levels of Proficiency in one line for every Employee. The table that stores the info in my SQL Database is this for example:
And the end result I would like to achieve is this:
Using Stuff function and xml path I have managed to create a select query that shows this:
But I can't find a way to insert a break line. The query will be used as a datasource for an AspxGridview.
Any help?
Thank you in advance!
My query so far:
select distinct
p.PersonID,
STUFF
( (SELECT char(10) + l.Language+' ('+ (case cvnl.Proficiency when 1 then 'Good'
when 2 then 'Very Good'
when 3 then 'Excellent'
end )
+') ' FROM CV_NewLanguages cvnl
inner join Languages l on l.LanguageID = cvnl.LanguageID
WHERE cvnl.PersonID = p.PersonID
ORDER BY l.Language ASC FOR XML PATH('')), 1, 1, '') AS Languages
from CV_Certifications cv
inner join person p on cv.PersonID=p.PersonID
inner join CV_NewLanguages cvnl on cvnl.PersonID=p.PersonID
inner join Languages l on l.LanguageID=cvnl.LanguageID
where active=1
group by
p.PersonID,
cvnl.Proficiency,
l.Language
order by p.PersonID
The result is this: enter image description here