Subject RE: [firebird-support] part of statements optional
Author Tim Gahnström
>From: Walter Ogston [mailto:ogstoncw@...]
>>In the simplest form I am asking for a way to have different where clauses
>>in select statements for instance.

>>Select * from table
>> If (condition) then
>> where a=b
>> else
>> where b=b

>Gotta drag my mind back to discrete math, boolean algebra etc. Does
> (condition and (a=b)) or (not condition and (c=b))
>do what you want?

My bad, to make it clear I simplified my problem to much. But it is true your solution solves this specific case reasonably well but it is not a solution for the general case where I want to make portions of SELECT statements dependant on parameters.

What I was really looking for in this case was mainly to have the order by clause depending on the parameter (I have solved my where clause issues with coalesce).

So the remaining real problem looks like this
Select * from table
where a=b
If (condition) then
Order by a
order by b

In MsSQL I think you can write it like this:

CASE WHEN condition b END ASC

I am sorry I simplified the first question into stupidity but I am still interested in an answer to the general question. Right now I have two large separate Select statements, this is both error prone and ugly.