Transposing SQL tables

0 like 0 dislike
2 views
faced with the task to transpose a table (turn 90 degrees).
there are columns
A | B | C
1 | 2 | 3
4 | 5 | 6

bring
A 1 4
B 2 5
C 3 6

on the Internet write
"my very strong advice: don't try to do this with SQL"
and a couple of rather "strange" options

What would you recommend?
by | 2 views

7 Answers

0 like 0 dislike
It is not entirely clear what type of data, but in any case fashionable simple enough to solve by using Dynamic SQL.
by
0 like 0 dislike
A | B | C
1 | 2 | 3
4 | 5 | 6
\r
bring
A 1 4
B 2 5
C 3 6
by
0 like 0 dislike
A | B | C
1 | 2 | 3
4 | 5 | 6
turn 90 degrees to the left:
3 6
B 2 5
A 1 4
\r
right:
4 1 A
5 2 B
6 3 C
\r
Transposition — replacing columns with rows, and not turn!
by
0 like 0 dislike
If the data are not over many and the task of single — procedure is very simple:
1. To consider everything.
2. Transpose.
3. To record everything.
by
0 like 0 dislike
I wonder where such a task.
\r
By the way, the DBMS essentially are able, in some sense, table transpose. This is called "index".
by
0 like 0 dislike
It is unlikely this will help, but in MS-SQL'e this is done with the help of the function PIVOT. Perhaps Google on "pivot in MySql" will help
by
0 like 0 dislike
when dumb muscle is to learn how to do
by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,186 answers
0 comments
1,117 users