April 19, 2012 at 10:29 am
Hi,
I need help in order to sort out following result set.
CREATE TABLE MYPARTS (PART_NO VARCHAR(10) NOT NULL, REPLACEMENT_PART_NO VARCHAR(10) NULL)
GO
INSERT INTO MYPARTS (PART_NO, REPLACEMENT_PART_NO) VALUES ('999' , '789');
INSERT INTO MYPARTS (PART_NO, REPLACEMENT_PART_NO) VALUES ('123' , '456');
INSERT INTO MYPARTS (PART_NO, REPLACEMENT_PART_NO) VALUES ('456' , '777');
INSERT INTO MYPARTS (PART_NO, REPLACEMENT_PART_NO) VALUES ('789' , '777');
INSERT INTO MYPARTS (PART_NO, REPLACEMENT_PART_NO) VALUES ('777' , '888');
INSERT INTO MYPARTS (PART_NO, REPLACEMENT_PART_NO) VALUES ('888' , NULL);
/* Required result set
PART_NOREPLACEMENT_LIST
999
123
456123
789999
777789,456,123,999
888777,789,456,123,999
*/
Any help will be appreciated.
Thanks,
FurrukH Baig
April 19, 2012 at 11:00 am
hey not clear as to what result are you wanting to see.. 😉
April 19, 2012 at 4:38 pm
Hi,
I want to see result as follows
PART_NO REPLACEMENT_LIST
999
123
456 123
789 999
777 789,456,123,999
888 777,789,456,123,999
this is complete hirerchy of replaced parts. like part 777 has replaced 456 and 789 and 456 did replaced 123 simillarly 789 replaced 999 hence result should contain all possible replacement as
777 789,456,123,999
please note 777 directly replaced 789 and 456 but indirectly it also is the replacement for 123 and 999.
thanks in advance
April 21, 2012 at 11:01 am
I have got the answer for my query.
please see the thread on following link.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=173784
Thanks,
Furrukh
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply