SELECT DISTINCT c.I D CompID, c.Com pName, c.P rovince, Arthur c. ity, c.D istrict, c.a. ddress, c.s. treet, c. apLng, c. apLat, c.Com pKind, c.a. ppArea, c. ainProduct,
(case when ISNULL (c. apLng) or ISNULL (c. apLat) THEN 100000000 ELSE round (6378.138 * 2 * asin (SQRT (pow (sin ((@ mapLat * PI ()/180 - c. apLat * PI ()/180)/2), 2) + cos (@ mapLat * PI ()/180) * cos (c. apLat * PI ()/180) (
* powSin ((@ mapLng * (PI)/180 - c. apLng * PI ()/180)/2), 2))) * 1000) END) short from eq e
Join co on e.Com pID c=c.I D
Left the join the class as a class on
FIND_IN_SET (class. The ID, the REPLACE (e.E qClassPath, '_', ', '))
And class. CPath LIKE '3383 \ _ %' and class. The State=0
WHERE c.s. Tate c.s. earchShow==1 and '0' and (e.S Tate=1 or e.S Tate=4) and e.I sPublic=1 and e.E ntityState <2;