select coalesce(avg(bar), 0) from foo;
Here is what the above code is Doing:
1. We’re creating a table called foo with two columns: bar and baz.
2. We’re inserting two rows into the table.
3. We’re selecting the average of the bar column from the foo table.
4. We’re printing out the result.