SQL Update Query Multiple Conditions

时间:2015-07-13 21:06:52

标签: sql sql-update

UPDATE Table
SET X = 0,Y = 0
From Table 
Where X > 9.99 or Y > 9.99

I need to set X's value to zero if it exceeds 9.99 and set Y's value to zero if it exceeds 9.99.

How can i achieve it in SQL.

Mine seems incorrect.

Please Help.

1 个答案:

答案 0 :(得分:1)

UPDATE your_Table
SET X = case when X > 9.99
             then 0
             else X
        end,
    Y = case when Y > 9.99
             then 0
             else Y
        end
WHERE X > 9.99 or Y > 9.99