By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
| amount | Group | discount_pct | rn | discount_amount | rest_amount |
|---|---|---|---|---|---|
| 100.00 | 1 | 0.500000 | 1 | 50.00 | 50.00 |
| 100.00 | 2 | 0.200000 | 2 | 10.00 | 40.00 |
| 100.00 | 3 | 0.250000 | 3 | 10.00 | 30.00 |
| amount | Group | discount_pct | rn | discount_amount | rest_amount |
|---|---|---|---|---|---|
| 100.00 | 1 | 0.500000 | 1 | 50.00 | 50.00 |
| 100.00 | 2 | 0.200000 | 2 | 10.00 | 40.00 |
| 100.00 | 3 | 0.250000 | 3 | 10.00 | 30.00 |