我想通过一些奇特的排名函数对我的postgres结果进行排序,但为了简单起见,假设我想添加两个自定义行并按它们排序。通过自定义命名行排序
SELECT my_table.*,
extract(epoch from (age(current_date, '2012-09-12 10:43:40'::date)))/3600 AS age_in_hours
Fancy_function_counting_distance() AS distance
FROM my_table
ORDER BY distance + age_in_hours;
但是,这是行不通的,因为我得到的错误:ERROR: column "distance" does not exist
。 是否可以通过该自定义命名行来排序我的结果?
我运行的Postgres 9.1.x
你的arent从调用完告诉它什么选择过吗? –
你是对的,抱歉,修正了示例查询。 – user1105595