For Item X on table '6' look for the order number for that item on table '7', where the quantity for the order/item on table '7' is greater than or equal to the quantity on table '6'. Once that criteria is met return the order number associated. Once an order number is used in "Order # to fill" column needs to pull the next order after which meets the criteria.
Table 6 - Unavailable | ||||
Order Number | Item Number | Request Date | Total | Order # to fill |
1128675 | AA | 7/15/2023 | 3 | |
1128675 | BB | 7/15/2023 | 1 | |
1128675 | CC | 7/15/2023 | 4 | |
1128979 | DD | 7/7/2023 | 2 | |
1128979 | CC | 7/7/2023 | 2 | |
1136911 | BB | 8/7/2023 | 5 | |
1136911 | AA | 8/7/2023 | 3 | |
1136911 | BB | 8/7/2023 | 2 | |
1136911 | CC | 8/7/2023 | 3 | |
1136911 | AA | 8/7/2023 | 4 | |
1136911 | AA | 8/7/2023 | 3 | |
1136911 | AA | 8/7/2023 | 3 | |
1136911 | DD | 8/7/2023 | 2 | |
1138934 | BB | 7/7/2023 | 2 | |
1138934 | CC | 7/7/2023 | 3 |
Table 7 - Available | |||
Item Number | Order Number | Request Date | Total |
BB | 1156793 | 8/14/2023 | 1 |
AA | 1156793 | 8/14/2023 | 1 |
CC | 1145608 | 8/14/2023 | 3 |
AA | 1156127 | 8/11/2023 | 2 |
AA | 1156126 | 8/11/2023 | 2 |
BB | 1156069 | 8/11/2023 | 6 |
CC | 1156091 | 8/11/2023 | 5 |
DD | 1156074 | 8/11/2023 | 3 |
DD | 1156073 | 8/11/2023 | 2 |
AA | 1156022 | 8/11/2023 | 3 |
AA | 1156020 | 8/11/2023 | 2 |
BB | 1156019 | 8/11/2023 | 1 |
CC | 1156013 | 8/11/2023 | 3 |
CC | 1156425 | 8/11/2023 | 1 |
AA | 1156129 | 8/11/2023 | 2 |