Evaluate only one CASE WHEN in a select

From: "dcrespo" <dcrespo(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Evaluate only one CASE WHEN in a select
Date: 2007-04-11 14:51:56
Message-ID: 1176303116.859653.47970@n59g2000hsh.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi everybody,

I'm implementing something like this:

SELECT
CASE WHEN add_numbers(t1.main_number,t2.main_number)>100
THEN t1.description1
ELSE t2.description1
END AS number_description1,
CASE WHEN add_numbers(t1.main_number,t2.main_number)>100
THEN t1.description2
ELSE t2.description2
END AS number_description2
FROM table1 t1, table2 t2;

Is there a way to evaluate the 'CASE WHEN' only once?

Thanks

Daniel

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Thompson 2007-04-11 15:01:49 Re: Acces via applets
Previous Message Tom Lane 2007-04-11 14:38:43 Re: 8.2.3 AutoVacuum not running