sql server use computed column

前端 未结 3 428
长情又很酷
长情又很酷 2021-01-18 06:19

I have a query like this:

select 
(price1 + price2 + price3) as total_price 
from prices

How can i use the computed column total_price to c

3条回答
  •  情深已故
    2021-01-18 06:56

    select T.total_price,
           P.price4 + T.total_price as total_price2
    from prices as P
      cross apply (select P.price1 + P.price2 + P.price3) as T(total_price)
    

提交回复
热议问题