0

我必须将查询从 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。有人可以帮助我吗?非常感谢!

4

0 回答 0