WeChat ID
aaronpk_tv
@aaronpk I’m gonna do this from now on when I have to write nontrivial sql
select
date,
sum(case when success = 1 then 1 else 0 end) as success,
sum(case when success = 1 then 0 else 1 end) as fail
from foo
group by date
order by date desc;
@aaronpk I know you're going to have to join the table twice, once where "success = 1" and second where "success = 0", probably where successdate (as date_format(date,'%Y-%m-%d')) = faildate (as date_format(date,'%Y-%m-%d')). But you have to get sums in there, too.
Now I need to watch this for someone to come in and solve it.
SUM(success = 0) as fail
SUM(1-success) as fail
COUNT(*)-SUM(success) as fail