Subject Re: [firebird-support] Creating a conditional "order by" statement
Author Svein Erling Tysvær
I even think Tomasz suggestion can be moved to the ORDER BY itself, at least it worked for me when I tried (well, I used iif(cast(:MyParameter as integer, Amount1, Amount2))

select ID, Amount1, Amount2, ...
from Table1
union
select ID, Amount1, Amount2, ...
from Table2
order by iif(your condition, Amount1, Amount2)

Set

2017-10-24 1:34 GMT+02:00 junk@... [firebird-support] <firebird-support@yahoogroups.com>:


Thanks for your reply. I haven't tried it as I came across Tomasz's suggestion first, and that works a treat!