SQL如果为null,则返回Float数据类型数字为空白

时间:2019-03-21 16:07:12

标签: sql postgresql

我有一个float数据类型列。我希望其中的空值在我选择时返回空白。 我尝试过:

case when Column is null then '' else Column end

但返回错误:

Invalid Syntax for float

1 个答案:

答案 0 :(得分:1)

''是一个空字符串,不能隐式转换为float。您可以返回NULL或将输出转换为文本。

select case when Col is null then '' else Col::text end from t;

Demo