By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
order_id | id | quantity | cancelled_date | created_date | cancelled |
---|---|---|---|---|---|
100000 | 1 | 100 | null | 2020-10-10 | False |
100000 | 2 | 200 | 2020-10-11 | 2020-10-10 | True |
100000 | 3 | 50 | null | 2020-10-12 | False |
100000 | 4 | 150 | null | 2020-10-12 | False |
100001 | 5 | 300 | 2020-10-12 | 2020-10-11 | True |
100001 | 6 | 300 | null | 2020-10-13 | False |
100001 | 7 | 50 | null | 2020-10-14 | False |
order_id | cancelled_id | quantity | substitute_id | quantity | qty_sum | parent_order_id |
---|---|---|---|---|---|---|
100000 | 2 | 200 | 3 | 50 | 50 | 2 |
100000 | 2 | 200 | 4 | 150 | 200 | 2 |
100001 | 5 | 300 | 6 | 300 | 300 | 5 |
100001 | 5 | 300 | 7 | 50 | 350 | null |
order_id | cancelled_id | substitute_id |
---|---|---|
100000 | 2 | 3 |
100000 | 2 | 4 |
100001 | 5 | 6 |
order_id | cancelled_id | cancelled_date | substitute_id | substitute_date |
---|---|---|---|---|
100000 | 2 | 2020-10-11 | 3 | 2020-10-12 |
100000 | 2 | 2020-10-11 | 4 | 2020-10-12 |
100001 | 5 | 2020-10-12 | 6 | 2020-10-13 |
order_id | cancelled_id | cancelled_qty | cancelled_date | substitute_id | substitute_qty | substitute_date |
---|---|---|---|---|---|---|
100000 | 2 | 200 | 2020-10-11 | 3 | 50 | 2020-10-12 |
100000 | 2 | 200 | 2020-10-11 | 4 | 150 | 2020-10-12 |
100001 | 5 | 300 | 2020-10-12 | 6 | 300 | 2020-10-13 |