试试这个,没有测试:
select date, sum(if(a = 1, 1, 0)) as A1, sum(if(a = 2, 1, 0)) as A2from tab where a=1group by date