Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Come utilizzare il campo calcolato in un altro campo della stessa query

Fallo in questo modo:

;WITH YourCTE AS
(
Select
    Case ...
        When ... then ...
        When ... then ...
        When ... then ...
    End                     as FieldA
From TblSource
)
SELECT FieldA, FieldA + 1 AS FieldB, FieldA + 2 AS FieldC ....
FROM YourCTE