fixing sql to give distinct points