Use value of a column for another column (SQL Server)?

后端 未结 4 1667
死守一世寂寞
死守一世寂寞 2021-02-19 00:02

lets say I have a huge select on a certain table. One value for a column is calculated with complex logc and its called ColumnA. Now, for another column, I need the val

4条回答
  •  一整个雨季
    2021-02-19 00:10

    You could:

    1. Do the + 10 in the client code
    2. Write a scalar-valued function to encapsulate the logic for complex stuff. It will be optimized into a single call.
    3. Copy complex stuff logic for the other column. It should get optimized out into 1 call.
    4. Use a sub-select to apply the additional calculation

提交回复
热议问题