0

My mysql table dummy looks like this:

name number some_value
A 1 1
A 2 4
A 3 7
B 1 1
C 3 5
C 4 4
... ... ...

And i want to join the table on itself by each distinct name value where the number equals and then select only some_value and number as index once. I know sound a bit messy so here would be the example from above:

number A.some_value B.some_value C.some_value ...
1 1 1 null ...
2 4 null null ...
3 7 null 5 ...
4 null null 4 ...

I would be very grateful if someone could help me and tell me the query to do that.

pssngr
  • 21
  • 7
  • What's the criteria for whether the value is in A, B, or C? – Barmar May 08 '22 at 12:59
  • For a start, this will need to be a LEFT JOIN to get null values. – Barmar May 08 '22 at 13:01
  • I the table at the beginning there is a column **name** with A,B,C, .. that defines if a the value of **some_value** is in the column A.some_value, B.some_value, ... . So to speak the **name** column at the beginning defines the position on the x-axis and the **number** column on the y-axis in the resulting table. – pssngr May 08 '22 at 13:10
  • Oh, then this is just a pivot of the table. – Barmar May 08 '22 at 13:12

0 Answers0