sacarmonar15
9/22/2017 - 5:20 PM

Massive Messages Report

#Reporte mySQL Envios Massivos.
select a.name as "Cuenta", 
year(mm.created_at), 
month(mm.created_at),
count(distinct mml.id) as "Encolados",
count(IF(mml.status=3,1,NULL)) AS "Con error",
(count(IF(mml.status=4,1,NULL)) + count(IF(mml.status=5,1,NULL))) AS "Enviados",
count(IF(mml.status=5,1,NULL)) AS "Abiertos"
from massive_messages mm
inner join accounts a on mm.account_id = a.id
inner join massive_message_logs mml on mml.massive_message_id = mm.id
where mm.draft = false and year(mm.created_at) = 2016 and month(mm.created_at) =11
group by a.id, year(mm.created_at), month(mm.created_at);