SELECT A.CANDIDATE_ID , A.CITY , A.STATE , A.POSTAL , B.LATITUDE + 360 , B.LONGITUDE + 360 FROM PS_FO_CANDIDATE_W A , PS_RS_GEOCODE_CITY B WHERE %Upper(A.CITY) = B.CITY AND A.STATE = B.STATE AND A.POSTAL = B.POSTAL UNION SELECT A.CANDIDATE_ID , A.CITY , A.STATE , A.POSTAL %Concat '-Error' , B.LATITUDE + 360 , B.LONGITUDE + 360 FROM PS_FO_CANDIDATE_W A , PS_RS_GEOCODE_CITY B WHERE %Upper(A.CITY) = B.CITY AND A.STATE = B.STATE AND B.LATITUDE = ( SELECT MIN(X.LATITUDE) FROM PS_RS_GEOCODE_CITY X WHERE X.CITY = %Upper(A.CITY) AND X.STATE = A.STATE) AND NOT EXISTS ( SELECT 'X' FROM PS_RS_GEOCODE_CITY C WHERE C.CITY = B.CITY AND C.STATE = B.STATE AND C.POSTAL = A.POSTAL) UNION SELECT A.CANDIDATE_ID , A.CITY %Concat '-Error' , A.STATE , A.POSTAL , B.LATITUDE + 360 , B.LONGITUDE + 360 FROM PS_FO_CANDIDATE_W A , PS_RS_GEOCODE_CITY B WHERE A.POSTAL = B.POSTAL AND A.STATE = B.STATE AND %Upper(A.CITY) <> B.CITY AND NOT EXISTS ( SELECT 'X' FROM PS_RS_GEOCODE_CITY C WHERE C.CITY = %Upper(A.CITY) AND C.STATE = A.STATE)
|