gpt4 book ai didi

sql - Oracle SQL CASE WHEN ORA-00932 : inconsistent datatypes: expected CHAR got NUMBER 00932. 00000 - "inconsistent datatypes: expected %s got %s"

转载 作者:行者123 更新时间:2023-12-04 22:30:50 25 4
gpt4 key购买 nike

获取错误
ORA-00932: inconsistent datatypes: expected CHAR got NUMBER 00932. 00000 - "inconsistent datatypes: expected %s got %s"
当我运行以下查询时

SELECT distinct 
CASE when t.cancelled = 'TRUE' then '0'
else t.amount END AMOUNT,
FROM table t

如果我为 else 输出使用数字或文本运行它,就像这样,它可以工作。
SELECT distinct 
CASE when t.cancelled = 'TRUE' then '0'
else 'xxx' END AMOUNT,
FROM table t

最佳答案

使用 0而不是 '0' .金额是一个数字,数字没有被引用。

SELECT distinct 
CASE when t.cancelled = 'TRUE' then 0
else t.amount END AMOUNT,
FROM table t

关于sql - Oracle SQL CASE WHEN ORA-00932 : inconsistent datatypes: expected CHAR got NUMBER 00932. 00000 - "inconsistent datatypes: expected %s got %s",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26678672/

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