Could you add a comment as to why your switching form SELECT DISTINCT * to SELECT DISTINCT cg.muid... Eg which column is missing that was causing the duplication.