我有两个带有dimtransport和dimsuburb的表,其列分别是运输(id,stopname,mode,lat,long)和郊区(id,郊区,城市,州,lat,long) 并且我想要具有(郊区,停车名城市)且半径小于1Km的城市和郊区的公用表,但是这些表之间没有任何关系。有人可以帮我吗?
我尝试使用cross join
,但是执行该过程大约需要20分钟-我可以在此解决任何问题吗
SELECT
t.stop_id,
s.suburb,
s.city,
t.stop_name,
t.mode,
s.lat,
s.lon,
t.stop_lat,
t.stop_lon,
(2 * 3961 * ASIN(SQRT(POWER((SIN(RADIANS((t.stop_lat - s.lat) / 2))), 2) +
COS(RADIANS(s.lat)) * COS(RADIANS(t.stop_lat)) *
POWER((SIN(RADIANS((t.stop_lon - s.lon) / 2))), 2)))) AS RAD
FROM
dbo.suburb s
CROSS JOIN
dbo.transport t
WHERE
(2 * 3961 * ASIN(SQRT(POWER((SIN(RADIANS((t.stop_lat - s.lat) / 2)))
, 2) + COS(RADIANS(s.lat)) * COS(RADIANS(t.stop_lat)) *
POWER((SIN(RADIANS((t.stop_lon - s.lon) / 2))), 2)))) <= 1000