Mysql
 sql >> Database >  >> RDS >> Mysql

MySQL GroupBy e lo mostra orizzontalmente

Prova questo,

SELECT  VendorID,
        SUM(CASE WHEN Score = 'A' THEN 1 ELSE 0 END) totalA,
        SUM(CASE WHEN Score = 'B' THEN 1 ELSE 0 END) totalB,
        SUM(CASE WHEN Score = 'C' THEN 1 ELSE 0 END) totalC
FROM    tableName
GROUP BY VendorID

Demo SQLFiddle