another SQL fix for postgres