4

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?

2
  • 2
    What is the view definition? I'm guessing the "empty" fields are null, so it might be as easy as using COALESCE(field, 0), but it's impossible to tell withough knowing how the view is generated. Commented Nov 13, 2016 at 17:51
  • Very good, that did the job! Thanks. Commented Nov 13, 2016 at 17:54

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.