【发布时间】:2016-02-15 07:32:22
【问题描述】:
我有一个包含三列整数值的表。在前两列中,我有一些值。现在我需要用其他两列的最小值更新第三列。
我试过使用
update table set col3 = (SELECT CASE WHEN (col2 is null OR col1 < col2 )
THEN col1
ELSE col2
END AS col3
FROM table
WHERE col1 is not null or col2 is not null)`.
但我收到如下错误:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
【问题讨论】:
标签: sql sql-server sql-update case