If a select statement returns no result, change the where condition I have two queries. I want to run the first select statement and only if it does not return any record then I want to run the second statement. How can I achieve this. These are my two statements:

select * from drscan.oem_program p 
WHERE upper(OEM_PROGRAMID) LIKE upper('%Subvented%')
  and oem_code = 'NCI'
  and rownum=1
  and p.ISACTIVE='Y'

select *
from drscan.oem_program p 
where oem_code ='NCI'
  and p.PROGRAMCATEGORY='NEW'
  and p.ISACTIVE='Y'
  and trunc(p.STARTDATE)&lt;=trunc(sysdate)
  and trunc(p.ENDDATE)&gt;= trunc(sysdate)
  and rownum=1
In SQL (not PL/SQL) you can do it like this:

with p as (
  select * from drscan.oem_program p 
  WHERE upper(OEM_PROGRAMID) LIKE upper('%Subvented%')
    and oem_code = 'NCI'
    and rownum=1
    and p.ISACTIVE='Y'
)
, p2 as (
    select *
  from drscan.oem_program p 
  where oem_code ='NCI'
    and p.PROGRAMCATEGORY='NEW'
    and p.ISACTIVE='Y'
    and trunc(p.STARTDATE)&lt;=trunc(sysdate)
    and trunc(p.ENDDATE)&gt;= trunc(sysdate)
    and rownum=1
)
select * from p
union all 
select * from p2 where not exists(select 1 from p)