I have the following query:
SELECT
,e.EmployeeCode
,c.CompanyName
,v.Violation
FROM dbo.Employee e
INNER JOIN dbo.Company c ON c.companyid = e.companyid
INNER JOIN dbo.Violation v ON v.CompanyId = e.CompanyId AND v.EmployeeId = e.EmployeeId
It returns results like the following:
EmployeeCode CompanyName Violation
1 Test 32
1 Test 12
2 ABC1 32
Row Count (3) <—-Not part of the results, just showing the number of rows I have.
Is there a way to return the results as so?
EmployeeCode CompanyName Violation
1 Test 32
12
2 ABC1 32
Row Count (2) <—-Not part of the results, just showing the number of rows I want.
Basically I want it to show the Violations with a cariage return in the same row.
I was thinking about using the FOR XML Path, but would this work with a carriage return? And how would I even do that?
I would suggest to do such transformations on application level where they really makes sense for some kind of reporting stuff.