I have 12 unique IDs in my PostgreSQL 9.5 table for which some array (text) are blanks:
ID(int) my_array(text)
1 1,112,298
2
3 2,114,235,145,126,123,141
.. ..
I am trying to replace these blank rows with '0'
in my query but so far failed to do so:
Select
Case when my_tbl.my_array = ' '
then '0'
else my_array
end as array
from my_table
The query runs but no result. Can somebody help to me to replace blanks rows using case statement or otherwise?
Use coalesce()
:
select id, coalesce(my_array, '0') as my_array
from my_table;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.