I have a data table
as follows:
id date1 date2 rate
1 01/01/2017 03/01/2017 0.60
1 02/01/2017 03/01/2017 0.40
1 03/01/2017 03/01/2017 0.00
1 04/01/2017 03/01/2017 0.00
1 05/01/2017 03/01/2017 0.00
2 . . .
For each id, I want to select the most recent positive value for rate
before it goes to 0. So since date2
's value is 03/01/3017
, the value of id 1's rate goes to 0 on 03/01/3017
. I want to choose the row where the rate is 0.40
.
I would want to do this for multiple ids. Also date2
can't be a weekend.