Fixes bug 1018349 - add COALESCE to max(sort) when adding a new product