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

asked 19 Sep '13, 05:52

mfkpie8's gravatar image

mfkpie8
86424852
accept rate: 10%

This forum is for answering questions about SQL Anywhere, not doing your homework.

(19 Sep '13, 07:49) Breck Carter
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×17
×16

question asked: 19 Sep '13, 05:52

question was seen: 515 times

last updated: 19 Sep '13, 07:49