Avoid null or undefined groups in distinct results