MySQL/MSSQL has a neat little inline if function you can use within queries to detect null values, as shown below.
SELECT ... foo.a_field AS \"a_field\", SELEC
Just do nvl(foo.bar,0), you don't have to do
nvl(foo.bar,0)
(select nvl(foo.bar,0)...