【Hive】order by count() 报错

匿名 (未验证) 提交于 2019-12-03 00:18:01

order by count(id) 报错

hive> select date, count(id) as idnum from test group by date order by count(id) FAILED:SemanticException[Error 10004]:...Invalid table alias or column reference 'id':(possible column names are:...)

修改为( 用别名idnum替换count(id) ),没有报错

hive> select date, count(id) as idnum from test group by date order by idnum

测试发现,在order by 中使用普通函数是可以的,但是不能使用聚合函数

hive> select to_date(time) as date, id from test order by to_date(time)

感觉很诡异,估计与运行顺序有关,如果各位大神知道原因,欢迎指导!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!