select a.date, round(count(case when a.type='no_completed' then 1 else null end)/count(a.id),3) as p from( select e.id,e.send_id,e.receive_id,e.type,e.date from email e left join user u on e.send_id = u.id where u.is_blacklist =0 )a join(select e.id,e.send_id,e.receive_id,e.type,e.date from email e ...