DontKnow DontKnow - 1 year ago 66
SQL Question

Oracle NOT pl/sql

I would like to do a select AFTER I do a case statment

i.e.

select x from dual ( x is actually a variable in a report writer tool)
case when x = 'equipment'
select * from inside_sales
else
select * from outside_sales
end


can't use PL/SQL

any help would be appreciated

Answer Source

I think you want this:

select * from inside_sales where x = 'equipment'
union all
select * from outside_sales where x <> 'equipment';

Note: The second condition is slightly more complicated if x can be NULL.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download