Select min value

R

Rafi

I have a query listing the transit time between two given origin points (zip
codes) and multiple destinations. I am trying to limit the results to the
one combination that list the smallest transit time -
Min(GND_TRANSIT.[SERVICE DAYS]) AS [Min DAYS]- and if the two origins have
equal transit times than select the one having the smallest value for Zone -
Min(GND_TRANSIT.ZONE) AS MinZONE. Unfortunately, the results show both
values rather than just obe row.

Your help is much appreciated.

SELECT DISTINCTROW GND_TRANSIT.DEST_ZIP, Min(GND_TRANSIT.[SERVICE DAYS]) AS
[Min DAYS], Min(GND_TRANSIT.ZONE) AS MinZONE, GND_TRANSIT.Origin
FROM GND_TRANSIT INNER JOIN Shipments ON (GND_TRANSIT.DEST_ZIP =
Shipments.DEST_ZIP) AND (GND_TRANSIT.DEST_ZIP = Shipments.DEST_ZIP)
GROUP BY GND_TRANSIT.DEST_ZIP, GND_TRANSIT.Origin;
 
A

akphidelt

This is untested but you might be able to

SELECT TOP 1

Then sort the Min Days ascending and MinZone as Ascending

Once again, untested but its something that could be pulled off
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top