Quantcast
Channel: IBM Mainframe Computers Forums
Viewing all articles
Browse latest Browse all 8500

DB2 :: RE: SQL query to run through list of values in table

$
0
0
Author: Rohit Umarjikar
Posted: Thu Dec 15, 2016 2:23 am (GMT 5.5)

Quote:
I see your code will give this for Case1:

I think, you missed to look at my order by.
Quote:
Let's say an ID=ID1 has the CODEs A,B,C,E,F. Since it has ANY one of the 'valid' IDs, my output will have only these:
Your left outer join will give this and not just ABC.
Code:
ID1 A
ID1 B
ID1 C
ID1 X
ID1 X

Quote:
Let's say another ID=ID2 has the CODEs E,F,G,H since none of them falls in the list of 'valid' CODEs, so the output will have these:

This will come 4 times unless we use DISTINCT.
Code:
ID2 X

_________________
Regards,
Rohit Umarjikar
"Knowledge is knowing that a tomato is a fruit, but Wisdom is knowing not to put it in a fruit salad."icon_razz.gif


Viewing all articles
Browse latest Browse all 8500

Trending Articles