【发布时间】:2022-01-14 21:23:07
【问题描述】:
我有一个表格,结果如下deduction_table-
| Person_number | eff_date | eff_end_dt | Deduction_taken | deduction_amount |
|---|---|---|---|---|
| 12 | 27/12/2020 | 01/12/2020 | Health Insurance | 8.9 |
| 13 | 17/12/2020 | 31/12/4712 | Life Insurance | 9 |
| 14 | 18/11/2020 | 01/01/2021 | Sigma | 10 |
当我将参数传递给 25/12/2020 和 06/01/2021 时,我应该得到以下结果 -
| Person_number | change_date | Deduction_code | deduction_amount |
|---|---|---|---|
| 12 | 02/12/2020 | ~Health Insurance | 0 |
| 13 | 17/12/2020 | Life Insurance | 9 |
| 14 | 01/01/2021 | ~Sigma | 0 |
所以当我传递参数dates时,我希望如果在传入参数to_date之前有一个effective end date,那么
deduction_amount 是 0 ,deduction_code 应该有 ~ 连接,change_date 是在 end date 之后的第二天。
另外,如果不是这种情况,那么change_Date 应该只是deduction_table 的有效开始。
【问题讨论】:
标签: sql oracle oracle-sqldeveloper