SQL Server Reference a Calculated Column

前端 未结 6 1061
傲寒
傲寒 2020-12-30 21:23

I have a select statement with calculated columns and I would like to use the value of one calculated column in another. Is this possible? Here is a contrived example to s

6条回答
  •  北海茫月
    2020-12-30 21:49

    Unfortunately not really, but a workaround that is sometimes worth it is

    SELECT [calcval1], [calcval1] * .25 AS [calcval2]
    FROM (SELECT [calcval1] = CASE Statement FROM whatever WHERE whatever)
    

提交回复
热议问题