Suppose I have log data like this:
2016-08-24 03:46:15 GMT vehicle_id="1075" vehicle_distance=145 stop_tag="5687" ... 2016-08-24 03:46:52 GMT vehicle_id="1075" vehicle_distance=19 stop_tag="5687" ... 2016-08-24 03:47:38 GMT vehicle_id="1075" vehicle_distance=47 stop_tag="5687"For a given vehicle, it shows its distance to the closest stop over time as data is transmitted occasionally by the vehicle. I want to select only those log entries where, for a particular vehicle/stop pair, the distance is the smallest. For this sample data, I'd want _only_ the middle entry because it has a distance of 19 that is the smallest among 19, 47, and 145. Note that the "..." above means that there are other log entries intermixed having different vehicles and their closest stops. I want this "smallest distance" log entry _every_ time the vehicle passes by the stop. For example, if the vehicle passed by the stop again two hours later (because it's done a complete loop of its route), I _still_ want the "smallest distance" from the first time it passed by _and_ the "smallest distance" from the second time it passed by --- and so on for every time it passes by the stop. The multiple "clusters" of vehicle/stop pairs should be considered independently when finding each "cluster's" smallest distance. How can I do this?