Elegabalus
Programmer
Bit of a stupid question, really, but most of the examples I've found through searching don't really do what I need.
I have two tables that are joined (person and person details).
When I pass in a person ID to get all the info on that person, multiple records are returned. I want to flatten the recordset out to one row. For instance:
I would like this to be:
The columns are NOT dynamic...they have to be there no matter what (so, if there are only two rows returned in the original query, the Person Phone3 column should be null).
I've tried using Case statements, but I can't quite seem to get the logic of it figured out.
Any help would be appreciated.
I have two tables that are joined (person and person details).
When I pass in a person ID to get all the info on that person, multiple records are returned. I want to flatten the recordset out to one row. For instance:
Code:
Person ID Person Phone
--------- -----------
1 555-123-1234
1 555-123-1235
1 555-123-1236
I would like this to be:
Code:
Person ID Person Phone1 Person Phone2 Person Phone3
--------- ------------ ------------- -------------
1 555-123-1234 555-123-1235 555-123-1236
The columns are NOT dynamic...they have to be there no matter what (so, if there are only two rows returned in the original query, the Person Phone3 column should be null).
I've tried using Case statements, but I can't quite seem to get the logic of it figured out.
Any help would be appreciated.