I have a question that is somewhat similar to this question already asked: Mysql, reshape data from long / tall to wide
My complexity comes with the fact that my data structure can be volatile and is subject to change at the user's discretion. So my columns can change aggregation (grow or shrink) depending upon the fields that populate the table.
For an example of what might be in my table, here are some records:
INPUT:
LOCATION User_Name Title Phone
Living Room Joe Schmo Worker 12-23
Baseball Park Jane Doe Worker 23-34
Backyard Tiger Woods Worker 34-45
but there's a fairly good amount of variability in the Title, and maybe even possibly in Location
INPUT:
LOCATION User_Name Title Phone
Living Room Batman Manager 9112
Baseball Park Batman Manager 9112
Backyard Batman Manager 9112
So what I need to do, on matched Locations, I need to have a wide table with all users associated to Location:
OUTPUT:
LOCATION User_Name Title Phone User_Name Title Phone
Living Room Joe Schmo Worker 12-23 Batman Manager 9112
Baseball Park Jane Doe Worker 23-34 Batman Manager 9112
Backyard Tiger Woods Worker 34-45 Batman Manager 9112
Any suggestions tips would be highly appreciated. I tried to replicate the example, but obviously how do I account for the fact that table can grow wider or narrow dynamically? I tried to do pivots but I couldn't get it to work with multiple fields.
Thoughts?