I have the following SQL in MySQL DB:
select code, distance from locations;
The output is below:
CODE DISTANCE LOCATION
106 386.895834130068 New York, NY
80 2116.6747774121 Washington, DC
80 2117.61925131453 Alexandria, VA
106 2563.46708627407 Charlotte, NC
106 2030.5845606766 Atalanta, GA
I want to be able to just get a single code and the closest distance. So I want it to return this:
CODE DISTANCE LOCATION
106 386.895834130068 New York, NY
80 2116.6747774121 Washington, DC
I originally had something like this:
SELECT code, min(distance), location
GROUP BY code
HAVING distance > 0
ORDER BY distance ASC