By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
PersonID | Visit_date | Medication_intake | Previous_date | Date_diff | Running_sum |
---|---|---|---|---|---|
1 | 2012-04-26 | 1 | null | null | null |
1 | 2012-11-16 | 1 | 2012-04-26 | 204 | 204 |
1 | 2013-04-11 | 0 | null | null | null |
1 | 2013-07-19 | 1 | null | null | null |
1 | 2013-12-05 | 1 | 2013-07-19 | 139 | 139 |
1 | 2014-03-18 | 1 | 2013-12-05 | 103 | 242 |
1 | 2014-06-24 | 0 | null | null | null |
2 | 2014-12-01 | 1 | null | null | null |
2 | 2015-03-09 | 1 | 2014-12-01 | 98 | 98 |
2 | 2015-09-28 | 0 | null | null | null |
Warning: Null value is eliminated by an aggregate or other SET operation.