select count(*), sum(t.realsalary)
from taxreport_temp t inner join employee e on t.id = e.id
where ( case
when e.housetax=1 then
4000
when e.housetax=0 then
1000
end)>=t.realsalary
from taxreport_temp t inner join employee e on t.id = e.id
where ( case
when e.housetax=1 then
4000
when e.housetax=0 then
1000
end)>=t.realsalary