I am using this command given by one of the experts to get the desired output on the basis of state,district,source.
Here there is only 2 tables.Similarly i want to append the result from other tables say t1 and t2 to this query, joining to be done on same fields.
WHEN rfeeddate between '2012-3-1' and '2012-3-31' THEN 1
END) as cnt,
WHEN rfeeddate<='2012-3-31' THEN 1
END) as cntTill
from mstchvs where flagr=1 and
group by state,district,source
order by 1,2,3