I need to show pivot table or crosstab like this, and my code below the table.
But the result is not the same as shown in the table.
Mach Name | 5 | 4 | 3 | 2 | 1 |
---|---|---|---|---|---|
Spring Assembly | Robatech | Panel Display | control | Air Leak | Cutter |
Spring Assembly | Inverter | Sensor | Conveyor | ||
Spring Assembly | No Power |
SELECT machtype AS Machine_Type,
CASE WHEN priors = '5' THEN problems ELSE NULL END AS '5',
CASE WHEN priors = '4' THEN problems ELSE NULL END AS '4',
CASE WHEN priors = '3' THEN problems ELSE NULL END AS '3',
CASE WHEN priors = '2' THEN problems ELSE NULL END AS '2',
CASE WHEN priors = '1' THEN problems ELSE NULL END AS '1'
FROM priority
I try this code but the result is not the same in the table that I shown above.