-- not what you want SELECT service_id, min(distance) FROM table GROUP BY service_id;