I have 2 sql database tables, DEMAND
. The table "Demand" has what's in demand with dates for items that need to be ordered. The "Demand" table is kind of like an MRP table. The "Order" table, is the purchase order table on materials being ordered.
I need to be able to join these 2 tables together, but only have it shown on the line that needs it. With the "Example1", the join is base off the "Item ID", but to have it shown in the correct line is base off the "Qty On Hand". The "Example1" diagram shows 0 on hand, so it's going to be needed on the first line. Now it runs out on Job ID 4715, so next job I need to align the next Order line with that line.
The example2, qty on hand has 3 on hand. So next time it run out will be on job 4715, so I need to have the first order item align with 4720 since those will be ordered and received. I then run out with that first order on job 4725, then I need to align the next order with job 4726.
I'm not even sure how to begin this so that I can align the right sales order to the demand line when it's needed per my example. Can such thing be done? If I join it by part ID, I have my demand repeating twice since I have 2 orders open, and they do not align when I need it. I need to align my demand line with the next order when it's needed per the above example.