gpt4 book ai didi

mysql - SQL 更改结果

转载 作者:太空宇宙 更新时间:2023-11-03 11:06:53 24 4
gpt4 key购买 nike

所以我有这段代码,它工作正常

SELECT NAME, 
Country,
NORMAL_STATE,
CURRENT_STATE
FROM SOMS_TABLE
WHERE SOMS_TABLE.NAME LIKE 'AR%' AND
NORMAL_STATE <> CURRENT_STATE
ORDER BY SOMS_TABLE.Country ASC

输出是
enter image description here

但我想将 1 和 0 更改为 OPEN & CLOSED

enter image description here
谢谢

最佳答案

select name,
Country,
case NORMAL_STATE
when 1 then 'OPEN'
when 0 then 'CLOSED'
else 'UNKNOWN'
end as NORMAL_STATE,
case CURRENT_STATE
when 1 then 'OPEN'
when 0 then 'CLOSED'
else 'UNKNOWN'
end as CURRENT_STATE
from SOMS_TABLE
where name like 'AR%'
and NORMAL_STATE <> CURRENT_STATE
order by Country

关于mysql - SQL 更改结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11316982/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com