Referencing function value inside CASE..WHEN
Hi,
In the following statement, does the custom function get executed twice?
SELECT
MY_FUNCTION(...),
CASE WHEN MY_FUNCTION(...) = '...' THEN '...' ELSE '...' END
...
...
If so, is there a way I can make it execute once? I tried this but it gave me a "Column my_function does not exist" error.
SELECT
MY_FUNCTION(...) AS my_function,
CASE WHEN my_function = '...' THEN '...' ELSE '...' END
...
...
Thank you in advance.
Hi
Le 19/06/2011 04:27, lover boi a 锟斤拷crit :
SELECT
MY_FUNCTION(...) AS my_function,
CASE WHEN my_function = '...' THEN '...' ELSE '...' END
...
...
WITH
T AS
(SELECT MY_FUNCTION(...) AS my_function, ...
)
SELECT CASE WHEN my_function = '...' THEN '...' ELSE '...' END
...
...
A +
--
Fr锟斤拷d锟斤拷ric BROUARD - expert SGBDR et SQL - MVP SQL Server - 06 11 86 40 66
Le site sur le langage SQL et les SGBDR : http://sqlpro.developpez.com
Enseignant Arts & M锟斤拷tiers PACA, ISEN Toulon et CESI/EXIA Aix en Provence
Audit, conseil, expertise, formation, mod锟斤拷lisation, tuning, optimisation
*********************** http://www.sqlspot.com *************************