New to MySQL and trying to carry something over from R.
I have a data table with two columns, similar to the following, with a level-2 id and a nested id:
level2id | nestedid |
1 | 1 |
1 | 2 |
1 | 3 |
2 | 1 |
2 | 2 |
...
I want to restructure the data using MYSql in a new table like this:
level2id | nestedid1 | nestedid2 | nestedid3 |
1 | 1 | 2 | 3 |
2 | 1 | 2 | |
...
This is so that I can later perform joins to extract information on the nested ids to create aggregate values for variables that relate to the level2 id. Trivial to do in R using reshape for "time-varying" data, but can't find an obvious solution to this particular format (i.e. where the data are not organized in terms of attribute names and attribute values in columns. Thanks in advance!