SQL Query - How to get all notes comma separated group by customer
| NoteKey | CustomerKey | Note | LastEditedTime |
|---|---|---|---|
| 1 | 18736673 | Accout access error, Contact Technical team. | 01/02/2013 |
SELECT n1.CustomerKey, (SELECT ','+ n2.Note+ ' Last Edited Time:' + convert(varchar(26),n2.LastEditedTime)
FROM Note n2
WHERE n1.CustomerKey= n2.CustomerKey
ORDER BY CustomerKey, Note
FOR XML PATH('')) AS CustNote
FROM Note n1
Group By n1.CustomerKey
No comments:
Post a Comment