I'd like to achieve something like this:
SELECT
(CASE WHEN ...) AS FieldA,
FieldA + 20 AS FieldB
FROM Tbl
Assuming that by "..." I've replaced a long and complex CASE statement, I don't want to repeat it when selecting FieldB
and use the aliased FieldA
instead.
Note, that this will return multiple rows, hence the DECLARE
/SET
outside the SELECT
statement is no good in my case.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…