定义变量,无效标识符。欧几里德距离

时间:2016-10-19 03:25:18

标签: sql oracle with-statement

oracle一直拒绝我在try子句中尝试调用经度的任何东西。

 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));

1 个答案:

答案 0 :(得分: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));