Please I need help on how I can transform the data that appears in the attached photo. Maybe Unpivot SQL?
1 Answer
select id,customer,"Auxiliary" as Aux_type,auxiliary1,value1
from input_table
union
select id,customer,"Auxiliary" as Aux_type,auxiliary2,value2
from input_table
union
select id,customer,"Auxdyeing" as Aux_type,auxdyeing1,value3
from input_table;
This should work I guess.
UNION/UNION ALL
most likely the best and only way possible in MySQL/MariaDB to unpivot....LATERAL
was only recently added: 8.0.14. But I would be tempted byUNION ALL