Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: conditional selection of 'AND' or 'Select' in Oracle
"Rohit Dhawan" <rohit_reborn_at_yahoo.com> wrote in message
news:c76d1c78.0404161545.7397755a_at_posting.google.com...
> I am working on Oracle reports . One of the parameters that a User
> inputs is
> 'report_type'. Now, is there a way to do the following within a SQL
> query with no use of procedures or functions.
>
> select blaa from foo where
>
> something = something
> // if report_type='some_data' then
> and somethingelse = something else
> //else do nothing
>
>
> Also, IS there a way of doing something like the following
>
> // if report_type='some_data' then
>
> select blaa from foo where
> something = something
> // if report_type='some_data' then
> and somethingelse = something else
> //else do nothing
>
> else
> select blass1 from foo where
> something = something
> // if report_type='some_data' then
> and somethingelse = something else
> //else do nothing
Could you be more vague about what you want?
Try to be more specific .. or else the answers would be something something.
I'm guessing that decode might be of help in what you want:
select col2
from foo
where col1 = 'X'
and col3 = decode('&report_type', 'CRITERIA1','Y',col3) /
select decode('&report_type','CRITERIA1', colx, coly)
from foo
where col1 = 'X'
and col3 = decode('&report_type', 'CRITERIA1','Y',col3) /
something like that ... unless you want something else :))))
Anurag Received on Sat Apr 17 2004 - 13:17:51 CDT