title: How can I alter this to run in postgresql?
body: <p>What needs changing for this to run in postgreSQL?</p>
  
  <p>I was given the piece of sql </p>
  
  <pre><code>UPDATE ACC
  SET ACC.ACC_EC = SITESmin.ACC_EC, 
      ACC.ACC_NC = SITESmin.ACC_NC
  FROM    ACC
         INNER JOIN LATERAL ( SELECT TOP 1
                                  *
                        FROM      SITES
                        ORDER BY  ( acc_ec - site_etg ) * ( acc_ec - site_etg ) + (acc_ncb - site_ntg ) * ( acc_ncb - site_ntg )
                  ) SITESmin;
  </code></pre>
  
  <p>It seems to be using SET but I do not know why, so if it's not needed drop it.
  I am trying to get postgresql to work out distances. For every record in file one I have to compare to 3300  records in file 2 and select the nearest. Received wisdom suggests an array solution for the 3300 but I do not know how to do that. Perhaps it it  a "sub query" in SQL. </p>
  
  <p>If I am permitted to upload samples I will do so, though I have the feeling this is not allowed?</p>
  
  <p>Here are the filed names </p>
  
  <pre><code>public.acc.Location_Easting_OSGR 
  public.acc.Location_Northing_OSGR
  "public"."Sites"."SITE_ETG" 
  "public"."Sites"."SITE_NTG" 
  </code></pre>