Bucket Filling SQL query CTE
问题 I want to achieve the below output from the given input tables. Input Table (Bucket to be filled) ID | FullCapacity | CurrentAmount ---+--------------+-------------- B1 | 100 | 0 B2 | 50 | 0 B3 | 70 | 0 Input Table (Filler Table) ID | Filler ---+------- F1 | 90 F2 | 70 F3 | 40 F4 | 20 Output table should have below showing filling process. ID | FullCapacity | CurrentAmount ---+--------------+-------------- B1 | 100 | 90 B2 | 50 | 0 B3 | 70 | 0 ---+--------------+-------------- B1 | 100 | 100