faberDB (5/5/2015)
I try to explain better.When I have to make the product I have to have all the needed quantity in my warehouse, ok?
So, in the sample data I can't produce my product on 2015-03-20 because I only have:
itemid avail Qty Needed qty
1 8 10
2 10 10
3 4 5
My need is to know the date for the entire BOM.
I'm sorry to not be able to explain me properly, thank you for your efforts.
I think maybe your process is a bit flawed here. Why do you need to determine when you might have been able to produce something in the past? It seems like you should have a production history table that maintains when something is made instead of trying to back into a possible date. Also, do you only ever produce one item at a time? I don't know what is being made but typically a manufacturing process includes a quantity to manufacture. The quantity of course is not needed when making larger items like cars or other items that can't be done in batches.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/