Postgres列“距离”不存在

时间:2016-05-30 07:21:23

标签: postgresql

我在select查询中创建了一个文字,最后我尝试使用having查找结果为distance < 50000的文字。

来自MySql背景,我认为此查询应该工作。

SELECT "description", 
       "location", 
       ST_Distance_Sphere(location, ST_MakePoint(-126.4,45.32)) AS "distance" 
FROM "news_agencies" AS "news_agencies" 
HAVING distance < 50000;

我还尝试在having >>>"distance"<<<文字周围添加引号。如果我删除“having distance < 50000”,我的查询运行正常并计算距离。这是我的错误:

column "distance" does not exist

1 个答案:

答案 0 :(得分:2)

您不能在123 子句中使用别名。试试这样:

having