on 2013 Sep 19 6:52 AM
with recursive ps(product_code,description,parent_id) as (select product_code,description,parent_id from product_code where parent_id='cp' union all select b.product_code,b.description,b.parent_id from ps p join product_code b on p.product_code=b.parent_id )
Put @result1 the results into the following query out the quantities of each layer
with recursive ps(product_code,description,parent_id) as (select product_code,description,parent_id from product_code where parent_id=@result1 union all select b.product_code,b.description,b.parent_id from ps p join product_code b on p.product_code=b.parent_id ) select shipper.customer_id,sum(sh.quantity),description=@result1 from (((select * from ps union all select product_code,description,parent_id from product_code where product_code=@result1 ) a join part on a.product_code=part.product_code) join shipper_line sh on part.part_id=sh.part_id) join shipper on sh.trans_no=shipper.trans_no group by shipper.customer_id,description
User | Count |
---|---|
68 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.