title: SQL query with inner join, acos and radians translation to Access
body: <p>I have to translate a query from SQL to Access query.
  This is the SQL query:</p>
  
  <pre><code>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&gt;=#2017-01-31 09:15:20# 
         AND p2.tempo&lt;=#2017-05-24 13:01:31# AND p2.flags&amp;1=1 
         AND NOT (p2.Lat=0 AND p2.Lon=0) ) as p2 
  WHERE p.idutenza = 2 AND p.tempo&gt;=#2017-01-31 09:15:20# 
    AND p.tempo&lt;=#2017-05-24 13:01:31#
    AND p.flags&amp;1=1 AND NOT (p.Lat=0 AND p.Lon=0) 
    AND ABS(timestampdiff(minute,p.tempo,p2.tempo))&lt;= 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) &lt;= 500
  </code></pre>
  
  <p>It works perfectly in MySQL.</p>
  
  <p>In Access it gives error in the <code>INNER JOIN</code>, Acos and Radians and really I don't know how to translate everything in order to work with Access.
  Someone could help me? Thanks a lot!</p>