0

I have this table,

category A_percent B_percent C_percent D_percent E_percent F_percent G_percent H_percent
First 78 21 67 12 45 15 34 78
Second 80 35 75 10 24 56 77 60
Third 90 56 63 3 32 45 87 23

Is there any way to turn that table into this kind of table in SQL?

item First Second Third
A_percent 78 80 90
B_percent 21 35 56
C_percent 67 75 10
D_percent 12 10 3
E_percent 45 24 32
F_percent 15 56 45
G_percent 34 77 87
H_percent 78 60 23

I've seen some of the examples and cases using PIVOT and UNPIVOT function, but the result is quite different that I want to have, and the data result that I want to have are not the aggregation of the table before, still the same value as before.

Currently all of the data are on MYSQL Server 5.7.22

P.S The actual column are more than 100 columns, so the table above are just an illustration.

forpas
  • 145,388
  • 9
  • 31
  • 69
terra
  • 11
  • 1

0 Answers0