Hive:按别名选择,按列名排序

时间:2017-02-06 10:18:57

标签: sql hive sql-order-by alias

当前查询,不起作用:

select datetime as a
from coffee_chain
order by datetime;

有人知道原因吗。

1 个答案:

答案 0 :(得分:0)

使用

select datetime as a from coffee_chain order by a;

https://issues.apache.org/jira/browse/HIVE-1449

hive> create table coffee_chain (datetime int);
OK

hive> select datetime as a from coffee_chain order by datetime;
FAILED: SemanticException Line 0:-1 Invalid table alias or column reference 'datetime': (possible column names are: a)
hive> select datetime as a from coffee_chain order by a;
OK