with temp1 as(
select to_char(sysdate - interval '1' month - (level-1) * interval '6' month,'yyyy-MM') as month from dual connect by level <= 6
)
inner join temp1 d on to_date(substr(mst.tally_date,0,7), 'yyyy-MM') <= to_date(d.month,'yyyy-MM') and to_date(substr(mst.tally_date,0,7), 'yyyy-MM') > (to_date(d.month,'yyyy-MM') - interval '6' month)
group by d.month