how to select max score from duplicate mobile_number greatest-n-per-group postgresql sql sql-order-by how can I filter record 60122839991 with the highest score 95.3758 and return as below without duplicate phone number AdvertisementAnswer Use distinct on: select distinct on (mobile_number) t.* from mytable t order by mobile_number, score desc