Adding distinct to sql