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

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

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

First of all thank you for your reply guys.
Sorry if i was not able to make requirment clear in first place.

Code:


Table 1 has only ID and there is no CODE column in it
Table 2 has CODE and no ID in it.

We match these tables based on some other common column.

Here is sample

Table 1

ID    timestamp   
abc    12:00
abc    13:00

Table 2

CODE
A
B1
C1

so one ID have three code. so here there will be total 6 rows.

The output expected is

Since A is onr of the valid code.

abc  A
abc  A

if there is no valid code

output expected is

abc X
abc X

so if valid value of code is there same value should be repeated for that ID (if there are multiple ID rows are there in Table 1) 

also in Table 2 there can be only one valid value of the CODE

that means there will be either A,B,C or D  though it may have any other values of CODE but valid value can only be one.

Hope i am claer  with requriment now.

_________________
Nitin gandhi


Viewing all articles
Browse latest Browse all 9405

Trending Articles