The reason for asking is to know whether it is generally more efficient to do e.g. SELECT CASE WHEN f(a, b) THEN ... END AS x, CASE WHEN f(a, b) THEN ... END AS y, CASE WHEN f(a, b) THEN ... END AS z FROM t; or to add an extra node that does nothing but gather the reused result e.g. SELECT CASE WHEN c THEN ... END AS x, CASE WHEN c THEN ... END AS y, CASE WHEN c THEN ... END AS z FROM ( SELECT f(a, b) AS c FROM t ) ; Assuming that f(a, b) does significant work (though it might not return Boolean as in the example).
|