Hi,
Although this is doable through SQL query, it is not recommended (performance wise). Simply because, the inventory on hand is a one number only but your goal is to distribute it among each detail line of sales orders.
It is better by some other tool such as Excel workbook to have 2 active worksheets linking to both tables. Then a formula would be much easier.
Thanks,
Gordon