I've got a SQL question. I want to use case logic to determine the value of an ad hoc column based on the result of comparisons done in the where clause. Simplified, I want to do something like this:
select t.id,
(case
when cond1 then "lbl1" + t2.v1
when cond2 then "lbl2" + t2.v1)
from
tbl1 as t left join tbl2 as t2
where
( cond1 || cond2 )
The problem is I don't want to recompute cond1 and cond2 in the select clause, as they're expensive.
How can I get this result?
Thanks, frood