Is there a way in TSQL to do something like this:
select a,b,c,
case
when a=1 then 5
when a=2 then 6
end as d
from some_table
where d=6
The actual case statement is really complex, so I’m trying to avoid repeating it in the where clause? Are there any tricks to do this?
(I think there’s a trick in MySQL to use “having d=6”).
1 Answer