SQL> select date_format(date_of_credit,'%b-%y'),sum(tot_01) as sum_tot01 from challan_detailsinner join master on master.code=challan_details.code where master.distcode in ('A','B') group by date_format(date_of_credit,'%b-%y');