如何使用cocece函数用字符串替换零值?
试图在选择语句中使用cocece函数将“无分配”放在零值。 这是代码:
SELECT ORDER_ID, ORDER_DATE,
coalesce (SALES_REP_ID,'NA') REP
FROM ORDERS```
[But having error "inconsistent datatype"]
How do I fix it?
[Data, in which sales_rep_id have null values which i want to change it to 'unassigned']
Trying to put 'unassigned' to the null values using coalesce function within the select statement.
Here is the code:
SELECT ORDER_ID, ORDER_DATE,
coalesce (SALES_REP_ID,'NA') REP
FROM ORDERS```
[But having error "inconsistent datatype"]
How do I fix it?
[Data, in which sales_rep_id have null values which i want to change it to 'unassigned']
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如错误所提到的那样,您正在混合数据类型。在
cocece
功能中,您需要先将sales_rep_id转换为varchar。As the error mentions, you are mixing data types. Inside the
coalesce
function you need to convert sales_rep_id to a varchar first.您需要确保不混合数据类型
You need to make sure you don't mix data types