944,168 Members | Top Members by Rank

Ad:
  • MS SQL Discussion Thread
  • Unsolved
  • Views: 2720
  • MS SQL RSS
Nov 6th, 2009
0

Connect by prior command

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sk.faheemuddin is offline Offline
1 posts
since Nov 2009
Nov 10th, 2009
0
Re: Connect by prior command
MS SQL Syntax (Toggle Plain Text)
  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. )
Reputation Points: 29
Solved Threads: 76
Practically a Master Poster
network18 is offline Offline
616 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in MS SQL Forum Timeline: Stored Procedures to insert into a table
Next Thread in MS SQL Forum Timeline: MS SQL Recursion problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC