I have a table with as structure like the following, with an unknown number of rows with each group index.
Group || PropertyA || PropertyB || PropertyC
============================================
1 || x1 || x12 || x13
2 || x21 || x23 || x23
3 || x31 || x32 || x33
3 || x41 || x42 || x43
... ... ... ...
I want all rows with the same Group index to be in a single row, concatenated, as follows:
Group || PropertyA || PropertyB || PropertyC || PropertyA1 || PropertyB1 || PropertyC1 ...
==================================================================================
1 || x1 || x12 || x13 || NULL || NULL || NULL
2 || x21 || x23 || x23 || NULL || NULL || NULL
3 || x31 || x32 || x33 || x41 || x42 || x43
... ... ... ...
I have attempted this using dynamic SQL, and have also attempted using pandas pandas.pivot() and pandas.pivot_table() but my skills with both have failed me so far. The database I have access to is SQL Server.
This issue is that I'm trying to add an unknown number of columns, as a Group index might appear multiple times.
Anything that even approximates the result could be a great help - the column names are unimportant, and can simply repeat. I just need all the data from each Group in one long row.
Any help is greatly appreciated.