Skip to content
Advertisement

How to return a value from a function if no value is found

I’m attempting to return 0.0 if the following function does not return anything:

I’ve tried searching for it and found that COALESCE does not work. Does anyone have any ideas how to solve this?

Table structure:

Example data:

Advertisement

Answer

Here is the script I used. As you can see I run PostgreSQL 9.4.1. I used HeidiSQL to launch the queries. Are you sure that you correctly updated your function? I just noted that you used a different function (‘player_height’) in a comment instead of ‘get_height’ in you original post.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement