select *, monthdiff/month_or_year as actdiff, CEILING(monthdiff/month_or_year) as rounddiff from
(select
TIMESTAMPDIFF(MONTH,date_of_agree,STR_TO_DATE(concat('".$year.",".$report_selected_month.",',date_of_month),'%Y,%m,%d')) as monthdiff ,
c.cust_name, c.cust_id, date_of_agree, month_or_year, date_of_month
from tbl_customer_master c
where c.month_or_year > 0 and c.date_of_agree != '0000-00-00' and date_of_month > 0
) as temptbl having actdiff=rounddiff