Fixed sqlcount to use distinct and remove groupBY