如何在PostgreSQL中将int转换为字符串

用户名

我有这个:COALESCE(amount ,0) as amount为数据类型amountnumeric

而不是0我想要N/A我怎样才能做到这一点?我收到错误消息:

ERROR:  invalid input syntax for type numeric: "N/A"
伊戈尔·科娃(Igor Cova)

您的情况更适合此代码: coalesce(cast(nullif(amount, 0) as text), 'N/A')

以及有关保存的其他信息:

case 
  when coalesce(cast(nullif(a.amount1, 0) as text), 'N/A') = 'N/A' then 'N/A' 
  when coalesce(cast(nullif(a.amount2, 0) as text), 'N/A') = 'N/A' then 'N/A'  
  else (coalesce(cast(nullif(a.amount1 - a.amount2, 0) as text), 'N/A')) 
end as savings

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Linux内核中将char []字符串转换为int?

如何在Golang中将数字(int或float64)转换为字符串

如何在Go中将int值转换为字符串?

如何在Kotlin中将Int转换为十六进制字符串?

如何在Swift中将Int转换为十六进制字符串

如何在PostgreSQL查询中将整数转换为字符串?

如何在C中将int转换为字符串?

如何在scala中将字符串数组转换为int数组

如何在C中将`int`数组转换为IP地址字符串?

如何在JS中将64位数字字符串转换为int

如何在PowerShell中将字符串值转换为键入“ System.Int32”

如何在PostgreSQL中将逗号分隔的字符串转换为数组

如何在inloop中将int转换为字符串

如何在python中将unsigned char类型的int字符串转换为int

如何在bash中将字符串转换为int?

如何在python中将字符串转换为int?

如何在C中将int转换为字符串(char *)

如何在C ++中将字符串转换为int?

如何在csv文件中将字符串转换为int?

如何在C#中将unicode字符串转换为int?

如何在存储过程中将字符串转换为int

如何在wpf中将int转换为字符串?

如何在laravel eloquent中将int转换为字符串?

如何在 Arduino 中将字符串转换为字符 *?

我如何在 Java 中将字符串 '$1400.00' 转换为 int 1400.00

如何在 CLASSIC ASP 中将字符串变量转换为 int,反之亦然

如何在Java中将字符串转换为int数组时抛出异常?

如何在 PostgreSQL 中将字符串值转换为日期格式?

如何在mongodb中将字符串转换为int