Oblomov
Oblomov

Reputation: 9635

Replacing empty integer cells with 0 in 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?

Upvotes: 4

Views: 1960

Answers (1)

Erwin Brandstetter
Erwin Brandstetter

Reputation: 656814

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

Upvotes: 4

Related Questions