SELECT
count(case when w_status = 'y' then 1 else 0 end) as c_y,
count(case when w_status = 'n' then 1 else 0 end) as c_n,
count(case when w_status = 'i' then 1 else 0 end) as c_i from view_working
where w_date BETWEEN '$date1' AND '$date2' and w_status='y' group by e_id order by c_y desc LIMIT 12