I will try and keep this as concise and easy to understand as possible. I have a dataset which includes a large number of names, some are distinct, however some are not and all names have a corresponding reference number. Where the names are not distinct, I want to create a query that will display a distinct list all of names in that table, and have seperate columns that list listing the reference numbers of the names in the original dataset. Is this at all possible using SQL? I was thinking a PIVOT clause might be required, but not sure that would be appropriate
Like below;
Current Dataset
FullName | Reference |
---|---|
Joe Bloggs | T1234567 |
Joe Bloggs | T3456789 |
John Smith | T1234568 |
Sarah Edwards | T1234567 |
Karen Culford | T0999221 |
Sarah Edwards | T0239222 |
Joe Bloggs | T2045292 |
Desired Outcome
FullName | Reference1 | Reference2 | Reference3 |
---|---|---|---|
Joe Bloggs | T1234567 | T3456789 | T2045292 |
John Smith | T1234568 | NULL | NULL |
Sarah Edwards | T1234567 | T0239222 | NULL |
Karen Culford | T0999221 | NULL | NULL |