Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Regarding the Assy Managment in Manufacturing, I have a sample table bellow.

SQLTable
ID ParentID Product AssyQty Description 
1   0        A      1      Finished Good
2   1        A1     2      one A product needs two A1 Products 
3   1        A2     2      one A product needs two A2 Products
4   2        A3     2      one A1 products needs 2 A3 Products 
5   3        A4     2      one A2 product needs 2 A4 Products


It's just the sample and the product can be in much deeper level. In case they need to produce ten A Products then I want to input @Product ='A' and @Muliplier =10 I need bellow result

Results
Product AssyQty Quantity Need 
A1      2        20 
A2      2        20 
A3      2        40 
A4      2        40


What I have tried:

I do not how to calculate to recursive using SQL server
Anyone can support me solve above query? Thank you
Posted
Updated 15-Sep-23 21:28pm
v2

1 solution

Time to start reading: Recursive CTE[^] - you will find plenty of material there, and it's far to big a subject for a little text box like this!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900