当一个客户有多个订阅时,它就会被复制。我想为整个客户状态生成一个 new_status,而不是为每个订阅生成一个新状态:一个重新激活订阅的客户和一个取消一个订阅但仍然有另一个活动订阅的客户。
东风:
Customer | Status | Canceled_at | Created | New_status
X | Active | |8/9/2017 |
X |Canceled | 8/3/2017 |6/19/2017 |
Y | Active | |2/13/2019 |
Y |Canceled | 11/28/2018 |10/14/2018|
Z | Active | |3/29/2018 |
Z |Canceled | 8/8/2018 |7/10/2018 |
A |Canceled | 9/2/2018 |7/10/2018 |
A |Canceled | 9/29/2018 |7/12/2018 |
A |Active | |5/31/2018 |
这些情况的条件是:如果取消重复的“canceled_at”日期>活动的“created”日期:如果取消重复的“canceled_at”日期<活动:new_status 将是“重新激活”
期望的输出:
Customer | Status | Canceled_at | Created | New_status
X | Active | |8/9/2017 |Reactivate
X |Canceled | 8/3/2017 |6/19/2017 |Reactivate
Y | Active | |2/13/2019 |Reactivate
Y |Canceled | 11/28/2018 |10/14/2018|Reactivate
Z | Active | |3/29/2018 |Downgrade
Z |Canceled | 8/8/2018 |7/10/2018 |Downgrade
A |Canceled | 9/2/2018 |7/10/2018 |Downgrade
A |Canceled | 9/29/2018 |7/12/2018 |Downgrade
A |Active | |5/31/2018 |Downgrade