I have a Table "Details" like this:
ID | BookID | Genre
_____________________________________________________
1 | 12 | AB
1 | 05 | AC
2 | 12 | AB
2 | 08 | BB
Is there any way to combine the rows in this format:
ID | BookID1 | Genre1 | BookID2 | Genre2
_____________________________________________________
1 | 12 | AB | 05 | AC
2 | 12 | AB | 08 | BB
I need to do it in such a format to add the respective columns to a stored procedure.
I generally would love to include some code or attempts but I'm clueless at this moment.
Not a Duplicate of the below: T-SQL dynamic pivot
1st difference im not using tsql
2nd difference is the structure of the table which can't be applied to mine.
My values are not going to be column headers instead they are gonna generate new columns such as :
ID | BookID1 | Genre1 | BookID2 | Genre2 | BookID3 | Genre3 | BookID4 | Genre4
1 | 05 | Horror | 12 | Horror | 03 | Drama | |
2 | 05 | Horror | 15 | Advent | 03 | Drama | 112 | RomCom
3rd Im not able to grasp the structure since I have zero knowledge of pivot tables