Mysql
 sql >> Datenbank >  >> RDS >> Mysql

MySQL GroupBy und Zeigt es horizontal an

Probieren Sie es aus,

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

SQLFiddle-Demo