Insert into targetable (dealernum, zipcode) SELECT dealernum, zipcode from sourcestable GROUP BY dealernum, zipcode HAVING distance = MIN(distance)
Dennis McGrath Software Developer QMI Security Solutions 1661 Glenlake Ave Itasca IL 60143 630-980-8461 [email protected] ________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of Dan Goldberg Sent: Tuesday, September 27, 2011 3:54 PM To: RBASE-L Mailing List Subject: [RBASE-L] - RE: select min command I thought of something like that but I need the minimum distance evaluated to get the dealernum and corresponding zipcode. Dan From: Dennis McGrath<mailto:[email protected]> Sent: Tuesday, September 27, 2011 1:20 PM To: RBASE-L Mailing List<mailto:[email protected]> Subject: [RBASE-L] - RE: select min command Insert into targetable (collist) select distinct collist from sourcetable Dennis McGrath Software Developer QMI Security Solutions 1661 Glenlake Ave Itasca IL 60143 630-980-8461 [email protected] ________________________________ From: [email protected] [mailto:[email protected]] On Behalf Of Dan Goldberg Sent: Tuesday, September 27, 2011 3:18 PM To: RBASE-L Mailing List Subject: [RBASE-L] - select min command I am having a brain fade and am trying to figure out how to get the minimum distance by zipcode. I have a table with the following values dealernum zipcode distance --------- -------- -------- CF001 93535 1.5 CF099 93535 1.8 CF011 93535 4.6 CF001 94000 2.5 CF099 94000 87.2 CF011 94000 17.9 What I need to do is store the dealernum and zipcode into a results table. dealernum zipcode --------- ------- CF001 93535 CF001 94000 I have played with min select function but cannot figure out the grouping to store both the dealernum and zipcode. TIA Dan Goldberg

