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

Necesita ayuda para crear una consulta MYSQL para contar dos contenidos de una sola fila/tabla

Consulta

SELECT t.`Create`, 
SUM(CASE WHEN t.`F_log` > 0 THEN 1 ELSE 0 END) as `F_log`,
SUM(CASE WHEN t.`C_log` > 0 THEN 1 ELSE 0 END) as `C_log` FROM(
    select `u_id`, `Create`,
    SUM(CASE WHEN `event` = 'F_log' THEN 1 ELSE 0 END) AS `F_log`,
    SUM(CASE WHEN `event` = 'C_log' THEN 1 ELSE 0 END) AS `C_log`
    FROM `Event`
    GROUP BY `u_id`, `Create`
)t
GROUP BY t.`Create`;