Hello guys! I'm struggling to achieve this, but I can't find the solution. What I need to do, is to count the records where the inquiry_date is older than the per_obs, for each per_obs, and make it accumulative for each id. So, it must restart when the ID changes. (the per_obs is set at the beginning of the month): This is the original table: ID INQUIRY_DATE PERIOD A 9/12/2019 2019-12 A 9/12/2019 2019-12 A 9/12/2019 2019-12 A 4/11/2019 2019-11 A 19/10/2019 2019-10 A 19/10/2019 2019-10 A 8/10/2019 2019-10 A 20/9/2019 2019-09 A 21/8/2019 2019-08 A 21/8/2019 2019-08 A 28/7/2019 2019-07 A 26/7/2019 2019-07 B 23/8/2018 2018-08 B 23/8/2018 2018-08 B 9/8/2018 2018-08 B 13/7/2018 2018-07 B 25/6/2018 2018-06 B 11/5/2018 2018-05 B 18/4/2018 2018-04 This is what I need: ID INQUIRY_DATE PERIOD Accumulative Inquiry dates A 9/12/2019 2019-12 9 A 9/12/2019 2019-12 9 A 9/12/2019 2019-12 9 A 4/11/2019 2019-11 8 A 19/10/2019 2019-10 5 A 19/10/2019 2019-10 5 A 8/10/2019 2019-10 5 A 20/9/2019 2019-09 4 A 21/8/2019 2019-08 2 A 21/8/2019 2019-08 2 A 28/7/2019 2019-07 0 A 26/7/2019 2019-07 0 B 23/8/2018 2018-08 3 B 23/8/2018 2018-08 3 B 9/8/2018 2018-08 3 B 13/7/2018 2018-07 3 B 25/6/2018 2018-06 2 B 11/5/2018 2018-05 1 B 18/4/2018 2018-04 0 Any help would be awesome, thanks a lot!
... View more