I have 3 tables – TableA, TableB and TableDetail
**Table Detail**
id FinalValue
1 99
2 88
3 77
**Table A**
id InitValue Num
1 10 100
2 30 200
**Table B**
id InitValue Num
3 20 200
My requirement is to get the FinalValue from TableDetail based on
Num
(Num value will be selected by user from a textBox UI).If TableB has a record for the partcular Num, then use Table B’s id.If not, then use Table A’s id.
The assumption is that Table A has records for all Num values.
For example,
If Num=200:
Since a record exists in TableB for Num=200, use TableB’s corresponding id (3) and get FinalValue from TableDetail where id=3, i.e.
FinalValue = 77
If Num =100:
SinceTableB does not have any record for Num=100,use TableA’s corresponding id (1) and get FinalValue from TableDetail where id=1, i.e.
FinalValue = 99
Can you plese help me frame a PL/SQL query for the same.Thanks!
try the following, @num is passed by user