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

buscando una ligera 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