I have a table like this:
╔════════╦═══╦═══╦═══╦═══╦═══╗
║ row_id ║ 1 ║ 2 ║ 3 ║ 4 ║ 5 ║
╠════════╬═══╬═══╬═══╬═══╬═══╣
║ 1 ║ T ║ E ║ S ║ N ║ U ║
║ 2 ║ M ║ B ║ R ║ H ║ A ║
║ 3 ║ C ║ D ║ F ║ G ║ I ║
║ 4 ║ J ║ K ║ L ║ O ║ P ║
║ 5 ║ V ║ W ║ X ║ Y ║ Z ║
╚════════╩═══╩═══╩═══╩═══╩═══╝
I want to "pivot" the table to get an outcome where the row_id
column is the first row, the 1
column the second etc.
The results should look like this:
╔════════╦═══╦═══╦═══╦═══╦═══╗
║ row_id ║ 1 ║ 2 ║ 3 ║ 4 ║ 5 ║
╠════════╬═══╬═══╬═══╬═══╬═══╣
║ 1 ║ T ║ M ║ C ║ J ║ V ║
║ 2 ║ E ║ B ║ D ║ K ║ W ║
║ 3 ║ S ║ R ║ F ║ L ║ X ║
║ 4 ║ N ║ H ║ G ║ O ║ Y ║
║ 5 ║ U ║ A ║ I ║ P ║ Z ║
╚════════╩═══╩═══╩═══╩═══╩═══╝
I've looked for ideas about Pivoting without aggregates but without much luck, mainly since the data I want to pivot is non numeric.
I've set up the sample data in SQL Fiddle.
Thanks!