Avatar of jdr0606
jdr0606Flag for United States of America

asked on 

Select smallest value from a list by categories

I have a process in which I'm trying to determine which is the shortest ship transit time from one location versus another.

For example if I'm shipping a package to first 3 digits of zip from zipcode 38133 it is 3 days but if shipping from zipcode 02189 it is 1 day I would want to select the transit day for 02189 at 1 day. For this example I have a table (have attached an example of the rows and values and I want to first select the transit days from the origin to the zip3 and then compare to all the origin transit days to the same zip3 and return the fastest (smallest vale).

Zip3      DestinationState      Zone      TransitDays      TransitType      OriginZip      Carrier
011      MA      2      1      FXG      02189      FedEx
011      MA      6      3      FXG      38133      FedEx
011      MA      8      5      FXG      97214      FedEx
011      MA      8      5      FXG      98108      FedEx

in the above the origin is 38133 with a transit of 3 and i'd want to compare to the resulting 02189 with 1 the shortest transit days.
Microsoft SQL Server

Avatar of undefined
Last Comment
Sharath S
Avatar of D B
Flag of United States of America image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Sharath S
Sharath S
Flag of United States of America image

Looks like all zip3s satisfy your requirement. Why specifically 011?
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo