Link to home
Start Free TrialLog in
Avatar of JDCam
JDCam

asked on

Oracle 10g - Modify select CASE

Experts,

I want to modify the query below.

Current behaviour:
SELECT PROBILL from TABLE A
IF PROBILL is NULL  SELECT MIN value from TABLEB

I have found that sometimes TABLEB is also NULL. If so, I want to return :Ordnum from the input.

SELECT CASE 
  WHEN PROBILL IS NULL
  THEN
    (Select MIN(myvalue) 
    From TABLEB 
    WHERE ORD_NUM = :Ordnum
    and COMP_CODE = :Comp)
  ELSE PROBILL
  END
FROM (SELECT MIN(WAY_BILL_NUM) PROBILL
  FROM TABLEA
  WHERE ORD_NUM = :Ordnum
  and COMP_CODE = :Comp)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Thomasian
Thomasian
Flag of Philippines 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
Avatar of JDCam
JDCam

ASKER

Excellent .... Works Great