Connect by prior command

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2009
Posts: 1
Reputation: sk.faheemuddin is an unknown quantity at this point 
Solved Threads: 0
sk.faheemuddin sk.faheemuddin is offline Offline
Newbie Poster

Connect by prior command

 
0
  #1
17 Days Ago
Hi All,
Can anybody give me a solution how to solve or write a query for this scenario?

there is table called ITT1 with the columns

FATHER, CHILD_NUM, CODE, CODE_QTY
a 1 b 1
b 1 c 1.5
c 1 d 2
d 1 e 1

There are 3 columns father,child_num,code & the code_quantity.
It is explained as 'a' is my FINAL finished good and is produced from raw material 'b' using 1kg.
and here 'b' becomes my finished good and is produced from raw material 'c' using 1kg.
and here 'c' becomes my finished good and is produced from raw material 'd' using 1kg.
and here 'd' becomes my finished good and is produced from raw material 'e' using 1kg.

now i want how much raw material 'e' is required to produced for eg. 20kg of 'a'

should i use connect by prior or sub queries will help in this regards.
kindly advice.

Regards,
Faheem
Reply With Quote Quick reply to this message  
Join Date: Sep 2009
Posts: 521
Reputation: network18 is an unknown quantity at this point 
Solved Threads: 60
network18 network18 is offline Offline
Posting Pro
 
0
  #2
13 Days Ago
  1. SELECT code_qty *10 FROM ITT1 WHERE code=
  2. (SELECT father FROM ITT1 WHERE code=
  3. (SELECT father FROM ITT1 WHERE code =
  4. (SELECT father FROM ITT1 WHERE code = 'a')
  5. )
  6. )
"The discipline of writing something down is the first step towards making it happen."

follow me on twitter
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC