我想在 SQL 中实现类似 Col3 = Col2 + Col1 的东西。
这有点类似于 Excel,其中第 3 列中的每个值都是第 2 列和第 1 列中相应值的总和。
最佳答案
A computed column is computed from an expression that can use other columns in the same table. The expression can be a noncomputed column name, constant, function, and any combination of these connected by one or more operators.
同样来自 CREATE TABLE J点
就像是
CREATE TABLE dbo.mytable
( low int, high int, myavg AS (low + high)/2 ) ;
关于sql - 我可以为 SQL 中的特定列设置公式吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2415398/