SQL列值更改

SQL列值更改,sql,sql-server,Sql,Sql Server,在我的数据库中,我有一个表,其中有一列result,其值为passed、failed、pending等。。如果我的结果值被传递,我必须将result=passed更改为result=corrected,如何在where子句中执行此操作。也就是说,若结果通过了,我想将通过的更改为更正的。我尝试了以下方法 select result as status, address + ' ' + city + ' ' + state + ' ' + zip as occupancy, name from O

在我的数据库中,我有一个表,其中有一列
result
,其值为
passed、failed、pending
等。。如果我的结果值被传递,我必须将result=passed更改为result=corrected,如何在where子句中执行此操作。也就是说,若结果通过了,我想将通过的更改为更正的。我尝试了以下方法

select result as status, address + ' ' + city + ' ' + state + ' ' + zip as occupancy, name 
from Occupancies OCC 
where (address like '%rd' or address is not null ) and
        case when result = 'Passed' then ' corrected';
我已经在where子句中使用了一些条件。任何建议都很好

只要:

SELECT CASE WHEN result = 'Passed' then 'corrected' end as Status, 
       address + ' ' + city + ' ' + state + ' ' + zip as occupancy, 
       name 
FROM Occupancies 

这是另一个黑暗中的镜头。在命名列和对象时,确实需要小心。使用保留字是一个坏习惯,会使查询变得比需要的困难得多。此外,当您像这样连接字符串值时,如果任何列为NULL,则结果将为NULL

select [status] = case when result = 'Passed' then 'corrected' end
    , [address] + ' ' + city + ' ' + [state] + ' ' + zip as occupancy
    , name 
from Occupancies OCC 
where result = 'Passed'

您得到的输出是什么?预期的输出是什么?您使用的是什么SQL-oracle、mysql、mssql..?不会对类似的SQL进行计算,因为NOTNULL也会覆盖类似的部分行。您可能需要
(像'%rd'这样的地址或地址为空)
。我正在使用sql server。所需的输出是我的值传递到的任何地方,而不是显示为已传递,它应该显示为已更正的状态。您得到了它……但解决方案是什么?您在多个回复上发布了相同的评论。