Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

procurando uma pequena variante de GROUP BY

SELECT T.attr,
       COUNT(Y.id)
FROM   (SELECT 'A' AS attr
        UNION ALL
        SELECT 'B') AS T
       LEFT JOIN YourTable Y
         ON Y.attr = T.attr
GROUP  BY T.attr