VBA提取最短距离

提取最短距离

SELECT D.LO1,D.LA1,D.LO2,D.LA2,D.DIS FROM  ( SELECT  A.LO AS LO1,A.LA AS LA1,B.LO AS LO2,B.LA AS LA2,111.12*atn(sqr(1-(SIN(a.LA*3.1415/180)*SIN(b.LA*3.1415/180)+COS(a.LA*3.1415/180)*COS(b.LA*3.1415/180)*COS((b.LO-a.LO)*3.1415/180))*(SIN(a.LA*3.1415/180)*SIN(b.LA*3.1415/180)+COS(a.LA*3.1415/180)*COS(b.LA*3.1415/180)*COS((b.LO-a.LO)*3.1415/180)))/(SIN(a.LA*3.1415/180)*SIN(b.LA*3.1415/180)+COS(a.LA*3.1415/180)*COS(b.LA*3.1415/180)*COS((b.LO-a.LO)*3.1415/180)))*180/3.1415  AS DIS  FROM [DX.CSV] A LEFT JOIN [YD.CSV] B ON A.LO<>B.LO AND A.LA<>B.LO) D ,(SELECT LO1,LA1,MIN(DIS) AS DIS_MIN FROM (SELECT  A.LO AS LO1,A.LA AS LA1,B.LO AS LO2,B.LA AS LA2,111.12*atn(sqr(1-(SIN(a.LA*3.1415/180)*SIN(b.LA*3.1415/180)+COS(a.LA*3.1415/180)*COS(b.LA*3.1415/180)*COS((b.LO-a.LO)*3.1415/180))*(SIN(a.LA*3.1415/180)*SIN(b.LA*3.1415/180)+COS(a.LA*3.1415/180)*COS(b.LA*3.1415/180)*COS((b.LO-a.LO)*3.1415/180)))/(SIN(a.LA*3.1415/180)*SIN(b.LA*3.1415/180)+COS(a.LA*3.1415/180)*COS(b.LA*3.1415/180)*COS((b.LO-a.LO)*3.1415/180)))*180/3.1415  AS DIS  FROM [DX.CSV] A LEFT JOIN [YD.CSV] B ON A.LO<>B.LO AND A.LA<>B.LO) GROUP BY LO1,LA1) C WHERE C.LO1=D.LO1 AND C.LA1=D.LA1 AND C.DIS_MIN=D.DIS

你可能感兴趣的:(VBA,sql)