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.
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
Table 2
so one ID have three code. so here there will be total 6 rows.
The output expected is
Since A is one of the valid code.
if there is no valid code
output expected is
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 clear with requirement now.
_________________
Nitin gandhi
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.
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
Code: |
ID timestamp abc 12:00 abc 13:00 |
Table 2
Code: |
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 one of the valid code.
Code: |
abc A abc A |
if there is no valid code
output expected is
Code: |
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 clear with requirement now.
_________________
Nitin gandhi