Subject Re: [IBO] Trick to use CASE WHEN to return two results
Author Cipto
If you are using Firebird 2.1+ maybe you can use built in function iif
(read the release notes of Firebird DB).

The iif function will not return 2 column but it more short function (in
arguments) than when..case

Hope this help.


----- Original Message -----
From: kokok_kokok
To: IBObjects@yahoogroups.com
Sent: Monday, July 30, 2012 7:14 PM
Subject: [IBO] Trick to use CASE WHEN to return two results

I have the typical structure

SELECT
WHEN
CASE <expr1> THEN val1
CASE <expr2> THEN val2
...
END
FROM MY TABLE

Is there a way or "trick" to return 2 values or columns in the same CASE
statement?

Now I need to repeat the WHEN...END statements for the second column, using
the same <expr> but changing only the <val>. It is a pain because the <expr>
are really long (several lines) and the SQL statement is more unreadable.

Thank you