[英]SQL Server 2005 : update the status column by comparing two values
I have a table where I have to check the values between column Value1
and value2
. 我有一个表,必须在其中检查列Value1
和value2
之间的value2
。 If value1
is less than value2
, update the status 'Low' in Status
column, if greater then update status to 'High'. 如果value1
小于value2
,更新状态“低” Status
栏,如果大于更新状态为“高”。
I have tried with this query 我已经尝试过此查询
UPDATE table
SET Status = If(value1 <= value2) Then 'Low' else 'High'
Please guide to a solution. 请指导解决方案。
This will work 这会起作用
UPDATE TABLE
SET Status =
CASE WHEN (value1 <= value2) THEN 'Low'
ELSE 'High' END
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.