- or download this
-- not what you want
SELECT service_id, min(distance) FROM table
GROUP BY service_id;
- or download this
SELECT stop_reference, service_id, distance FROM table
ORDER BY service_id, distance;
- or download this
my $last_service_id = -8675309; # for a good time, call
while ($sth->fetch()) {
...
$last_service_id = $service;
}
}