sql >> Base de Datos >  >> RDS >> Mysql

Convertir fila sql en columnas

SELECT A,
MAX(CASE WHEN B=1 THEN c END) AS C1,
MAX(CASE WHEN B=2 THEN c END) AS C2, // etc for B=3,4
FROM table1
GROUP BY A