定义变量,无效标识符。欧氏距离

defining variable, invalid identifier. Euclidean Distance

oracle 一直拒绝我尝试在 with 子句中调用经度的任何内容。

 WITH params as (
      SELECT -28 as lat, 151 as lon
      FROM dual
     )
SELECT sighting_id 
FROM sightings 
ORDER BY sqrt(power(lat - latitude, 2) + power(lon - longitude, 2));

您在 WITH 中定义参数,但从未在 FROM 中引用它。

WITH params as (
      SELECT -28 as lat, 151 as lon
      FROM dual
     )
SELECT sighting_id 
FROM sightings CROSS JOIN params 
ORDER BY sqrt(power(lat - latitude, 2) + power(lon - longitude, 2));