select t1.sales_reg,t1.pack_cod,(100-(((t1.total)-(t2.total))*100)/t1.total) as ret_per from (select sales_reg,pack_cod,sum(pre_ret+post_ret)as total from projection where no_of_mon =1 group by sales_reg,pack_cod having sum(pre_ret+post_ret)>100) as t1,(select sales_reg,pack_cod,sum(pre_ret+post_ret) as total from projection where no_of_mon =2 group by sales_reg,pack_cod having sum(pre_ret+post_ret)>100) as t2 where t1.sales_reg=t2.sales_reg and t1.pack_cod=t2.pack_cod and t1.total>=t2.total order by 3 desc limit 5; sales_reg | pack_cod | ret_per -----------+----------+-------------------------- 80 | 1699-02 | 100.00000000000000000000 4444 | COR0054 | 100.00000000000000000000 4444 | CUGNFT1 | 100.00000000000000000000 80 | CUGNFT1 | 100.00000000000000000000 80 | CUGTY1 | 100.00000000000000000000 now i need to see the no of cutomers for each month for the above results