Changed group by to distinct

Changed group by to distinct as group by changes the order