mav*_*ick 42 sql postgresql null max
当我执行
select max(column) from mytable;
Run Code Online (Sandbox Code Playgroud)
并且我的表没有行,它返回null.如何修改此select语句以使其返回零?
Mar*_*ers 82
select coalesce(max(column), 0) from mytable;
Run Code Online (Sandbox Code Playgroud)
这两个都行吗?
select coalesce(max(foo),0) from bar
Run Code Online (Sandbox Code Playgroud)coalesce((select max(foo) from bar),0)
Run Code Online (Sandbox Code Playgroud)