如何在SQL中将值表示为别名

Val*_*ion 0 sql sql-server

有没有办法根据结果本身将SQL查询的结果表示为不同的值?例如,每次数据库中的实际值为'foo'时,我希望表中的结果显示为'bar'.

jue*_*n d 5

用一个 case

select case when col1 = 'foo' 
            then 'bar'
            else col1 
       end as col1
from your_table
Run Code Online (Sandbox Code Playgroud)