Subject RE: [firebird-support] Conditional/alternative where clauses
Author Paul Lopez
> Is there a way to do something like this:
>
> select <Field1, Field2, Filed3>
> from Table1
> if (field1 = 6) then
> where (Field2 between '3/1/2011' and '3/31/2011') else where field2
> between '3-1-2012' and '3-22-2012')
>
> I've tried this, and other variations (including When and Case), but no luck. I
> was hoping to do this to create a view.

Hi,

Try this:

select 1, 2, 3
from rdb$database
where ( field1 = 6 and Field2 between '3/1/2011' and '3/31/2011' )
or ( field1 <> 6 and field2 between '3-1-2012' and '3-22-2012' )

Depending on how much data you're grabbing, the OR may cause some performance issues.

If this does not help, then maybe can you send a more specific example and what you are trying to achieve.

Paul.