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;
akphidelt - 17 Apr 2008 17:59 GMT
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
> 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
[quoted text clipped - 11 lines]
> Shipments.DEST_ZIP) AND (GND_TRANSIT.DEST_ZIP = Shipments.DEST_ZIP)
> GROUP BY GND_TRANSIT.DEST_ZIP, GND_TRANSIT.Origin;