Lax Mandis
Lax Mandis

Reputation: 131

SQL return a Float data type number as blank if null

I have a float datatype column. I want the null values in that to be returned as blank when I select it. I tried this:

case when Column is null then '' else Column end

but it returns an error:

Invalid Syntax for float

Upvotes: 2

Views: 4564

Answers (1)

Kaushik Nayak
Kaushik Nayak

Reputation: 31736

'' is a blank string and can't be implicitly cast to float. You may either return NULL or cast the output to text.

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

Demo

Upvotes: 1

Related Questions