question

ashish420 avatar image
ashish420 asked

Id matches same table different columns

ID ID_1 ID_2 ID_3 1 1 NULL 1 2 1 2 1 3 3 2 1 4 3 3 NULL 5 NULL 3 NULL 6 NULL NULL 6 7 7 NULL 6 8 7 8 NULL 9 NULL 8 NULL Hello, Please refer the above ID Related_ID 1 1 2 1 3 1 4 1 5 1 6 6 7 6 8 6 9 6 The ID_1, ID_2 are the same ID as per first column but related....I need to produce a final output with min of related ID.... Please can you help me construct the query Thanks
sql-server-2008tsql
11 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ashish420 avatar image ashish420 commented ·
Sorry the table was not pasted well what I meant was that the table has ID ID_1 ID_2 ID_3 and so on now ID 1 is related to ID 2 so will be captured as ID ID_1 1 1 2 2 same goes on and finally I have to work out all that match each other Thanks
0 Likes 0 ·
KenJ avatar image KenJ commented ·
is this the desired output? ID ID_1 1 1 2 2 It is not apparent to me from the question what the desired result is.
0 Likes 0 ·
ashish420 avatar image ashish420 commented ·
This is the desired result ID Related_ID 1 1 2 1 3 1 4 1 5 1 6 6 7 6 8 6 9 6
0 Likes 0 ·
ashish420 avatar image ashish420 commented ·
ID Related_ID 1 1 2 1 3 1 4 1 5 1 6 6 7 6 8 6 9 6 This is the desired result
0 Likes 0 ·
ashish420 avatar image ashish420 commented ·
Sorry the format is not correct when pasted please refer the image file https://drive.google.com/open?id=0BxXB4ngfzwLTVVRlTU12NFRkSU0 the first part of table is input and second part is output
0 Likes 0 ·
Show more comments

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.