Link to home
Start Free TrialLog in
Avatar of JDCam
JDCam

asked on

Oracle 10g - Select based on outcome of first select

Experts,
An easy one today...

I have two working select statements. I need to combine them so that if my input variable matches the first select, I return the results of the second select. If the Variable does not match, nothing should be returned.

Please help me with the syntax

IF vQTY = (
Select 
ITEM_QTY_BKD_QTY 
from M_Item_D1 where comp_Code = 'T2' 
and Cust_Code = 'BARITEST' 
and Item_Code = '003562' 
and ITEM_QTY_BKD_LEV_NUM = 1)

select
ITEM_QTY_BKD_NUM_LAY LAYERS,
ITEM_QTY_BKD_QTY_PER_LAY QTY
from M_Item_D1 where comp_code = 'T2' 
and cust_code = 'BARITEST' 
and item_code = '003562'
and item_qty_bkd_lev_num = 1

Open in new window

Avatar of Alex [***Alex140181***]
Alex [***Alex140181***]
Flag of Germany image

why not simply join these tables?!
ASKER CERTIFIED SOLUTION
Avatar of johnsone
johnsone
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
No need to join tables, it is the same table.
Avatar of JDCam
JDCam

ASKER

Wow... I was trying way too hard and looked right past the obvious.
thanks
No need to join tables, it is the same table.

I didn't mean it that way ;-)

I was aware of that fact