how to get overdue complaints using join two tables First table

Complaint_id         Completetion_date        Templateid
53035                 2018-11-16 00:00:00        5                
47956                2018-11-03 00:00:00        13
3953                 2017-11-27 00:00:00        17


Second table

Template_month                        id
8                                      5
6                                      13
4                                      15
2                                      17


In first table completion date is 16 Nov 2018 and tempalteid is 5 and in the second table id 5 have 8 month means need to calculate 8 months from 16 nov this is not overdue complaint. In the second row of first table completion date 2018-11-03 00:00:00   having templateid 13 and in the second table there is 6 month means periods is overdue then in the result 3953 is overdue id

I am using this query 

select complaint_id 
from complaints as comp 
INNER JOIN template ON comp.templateid=template.id 
where comp.completion_date::date + ('interval ' || template.template_month::text || ' month')
You can't create an interval like that. To have a variable number of months,  create a 1 month interval and multiply it with your number of months. 

You also need to compare the result of adding the interval to the completion date to something. I assume you want to compare it to "today":

select comp.complaint_id 
from complaints as comp 
  JOIN template as tmpl ON comp.templateid = tmpl.id 
where comp.completion_date + interval '1 month' * tmpl.template_month &lt; current_date;


Online example: https://rextester.com/JGNX75589