select
A.ACCOUNT1 AS ORIGINAL_ACCT_NO,
A.ACCOUNT2 as ACCT_MATCH,
A.EXACT_DISTANCE as DISTANCE
from
BA_TEMPDB.pharmacy_distance A,
N433M4_ALL_INDIES_GT_10MILES B
where
A.ACCOUNT1 = B.ACCOUNT_NO
This gives me over 52000 rows and multiple instances of account1, I need to select
A.ACCOUNT1 AS ORIGINAL_ACCT_NO,
A.ACCOUNT2 as ACCT_MATCH,
A.EXACT_DISTANCE as DISTANCE
where it selects the closest account2 based on distance. I know I need some kind of derived query where I need to use the min function for distance, but stumped as to how to word the query.
Thanks!
QueryMan
A.ACCOUNT1 AS ORIGINAL_ACCT_NO,
A.ACCOUNT2 as ACCT_MATCH,
A.EXACT_DISTANCE as DISTANCE
from
BA_TEMPDB.pharmacy_distance A,
N433M4_ALL_INDIES_GT_10MILES B
where
A.ACCOUNT1 = B.ACCOUNT_NO
This gives me over 52000 rows and multiple instances of account1, I need to select
A.ACCOUNT1 AS ORIGINAL_ACCT_NO,
A.ACCOUNT2 as ACCT_MATCH,
A.EXACT_DISTANCE as DISTANCE
where it selects the closest account2 based on distance. I know I need some kind of derived query where I need to use the min function for distance, but stumped as to how to word the query.
Thanks!
QueryMan