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

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

$
0
0
Author: Ni3-db2
Subject: SQL query to run through list of values in table
Posted: Wed Dec 14, 2016 9:52 am (GMT 5.5)

I have a below query,i tried it but not able to come up with the exact solution.
I have two tables.
Table 1 has a column ID and table 2 have column CODE
NOW for every ID in table 1 there can be multiple rows in table 2 with different values of CODE.

I have to write a query such that for every ID in table 1 search (run through) table 2 to select a code which is valid( it will be valid if it has any of the value A,B,C,D) IF it is not valid make the code as X.

finally sort the output in specific order of code like X,B,A,C,D

Any suggestions/ help will be greatly appreciated.
_________________
Nitin gandhi


Viewing all articles
Browse latest Browse all 8500

Latest Images

Trending Articles



Latest Images