sql - Where date difference between now and max date value is greater than X -
i want return result set (from postgres database) containing clients last payment date more x number of days ago.
this have list of clients , last payment date:
select usermaster.userid, date_trunc('days', now()-max(paymentdate)) last_payment usermaster, paymentdetail usermaster.userid=paymentdetail.userid group usermaster.userid; i limit condition: ... , last_payment > 100 days
this should trick
edit -
select * (select usermaster.userid, date_trunc('days', now()-max(paymentdate)) last_payment usermaster, paymentdetail usermaster.userid=paymentdetail.userid group usermaster.userid ) temptab last_payment>100;
Comments
Post a Comment