Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing empty integer cells with 0 in postgreSQL

Tags:

sql

postgresql

I have a view

matches_view

returning the following:

 id |      name      | wins | losses | matches
----+----------------+------+--------+---------
  2 | Peter          |    1 |      2 |       3
  1 | Kevin          |    3 |      1 |       4
  3 | John           |      |      1 |

How can I replace the empty columns in the last row with 0s in postgreSQL?

like image 587
user1934212 Avatar asked Oct 15 '25 15:10

user1934212


1 Answers

You can use COALESCE(<expression>, 0) for numeric columns in any case.

like image 51
Erwin Brandstetter Avatar answered Oct 18 '25 07:10

Erwin Brandstetter