November 8, 2012 at 3:30 am
Hello,
How can i merge same fields different values to one value?
eg. tblEmployee table and output is,
Date Employee Summary
07/11/2012 Susan Job 1 Done
07/11/2012 Susan Job 2 Done
07/11/2012 Mike Job 11 Done
07/11/2012 Mike Job 12 Done
Desire Output:
Date Employee Summary
07/11/2012 Susan Job 1 Done and Job 2 Done
07/11/2012 Mike Job 11 Done and Job 12 Done
November 8, 2012 at 3:48 am
google:
T-SQL concatenate string FOR XML PATH
November 8, 2012 at 3:48 am
No EmployeeId? Why? You might have two employees with the same name..
SELECT DISTINCT
EmployeeId ,
Date ,
Employee ,
STUFF(( SELECT ' and ' + t2.Summary AS [text()]
FROM tblEmployee t2
WHERE t2.EmployeeId = t1.EmployeeId
FOR
XML PATH('')
), 1, 5, '') AS Summary
FROM tblEmployee t1
November 8, 2012 at 4:03 am
You are Super Star clayman, make my day
There is EmployeeID, it was just example and in a rush didn't define.
Thanks Again.
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy