我必须将查询从SQL转换为Access查询。 这是SQL查询:
SELECT ABS(timestampdiff(minute,p.tempo,p2.tempo)) as tempoDifferita,
ABS(6372.7954775979997 (Acos( Sin(RADIANS(p.lat)) Sin(RADIANS(p2.lat)) +
Cos(RADIANS(p.lat)) Cos(RADIANS(p2.lat))
Cos(ABS(RADIANS(p.lon) - RADIANS(p2.lon)))))*1000) AS distanza,
p.idutenza,p2.idutenza as idutenza2, p.tempo, p2.tempo as tempo2,
p.lon,p.lat, p2.lon as lon2, p2.lat as lat2, p.velocita,
p2.velocita as velocita2, p.indirizzo,p2.indirizzo as indirizzo2,
p.nsat, p2.nsat as nsat2, p.direzione, p2.direzione as direzione2,
p.flags, p2.flags as flags2
FROM punti as p
INNER JOIN
(SELECT FROM punti AS p2
WHERE p2.idutenza = 1 AND p2.tempo>=#2017-01-31 09:15:20#
AND p2.tempo<=#2017-05-24 13:01:31# AND p2.flags&1=1
AND NOT (p2.Lat=0 AND p2.Lon=0) ) as p2
WHERE p.idutenza = 2 AND p.tempo>=#2017-01-31 09:15:20#
AND p.tempo<=#2017-05-24 13:01:31#
AND p.flags&1=1 AND NOT (p.Lat=0 AND p.Lon=0)
AND ABS(timestampdiff(minute,p.tempo,p2.tempo))<= 60
AND ABS(6372.7954775979997 (Acos( Sin(RADIANS(p.lat))
Sin(RADIANS(p2.lat)) + Cos(RADIANS(p.lat))
Cos(RADIANS(p2.lat)) * Cos(ABS(p.lon - p2.lon))))*1000) <= 500
它在MySQL中完美运行。
在Access中,它会在INNER JOIN
,Acos和Radians中出错,而且我真的不知道如何翻译所有内容以便使用Access。
有人可以帮帮我吗?非常感谢!