Thank you so much it works! But I think that it doesn't do what i need.
Indeed, I have a database with people who made two purchases at two differents dates.
There is one row for one purchase by client. The date of purchase is INCIDENCE_DATE(format %Y%m%d), and I want to classify for people who buy two times, in fonction of the difference of time in months between the two date. I want to classify in a new column Class_S, only the most recent order.
For example with this data :
id/name/incidence_date
12/patrick/20161211
12/patrick/20181211
32/madison/20150211
45/james/20140215
45/james/20140515
I want to have this (diffDateMonths is only indicative)
id/name/incidence_date/diffDateMonths/Class_S
12/patrick/20161211/24/
12/patrick/20181211/24/VERIF
32/madison/20150211/
45/james/20140215/3/
45/james/20140515/3/
As my date to compare are in different rows but in the same colum, that's why I think about made a loop for to do this. Maybe this is not the best idea?