hive中使用order by时发现的小问题:Line 3:9 Invalid table alias or column reference ‘history_sort‘

执行的sql:

select learning_position_id,learning_path_id
from position_course_sort
order by history_sort,recommend_sort,hot_sort

报错信息:

FAILED: SemanticException [Error 10004]: Line 3:9 Invalid table alias or column reference 'history_sort': (possible column names are: learning_position_id, learning_path_id)

报错原因:
select 后面的字段必须包含order by后面的所有字段,不然就会报上面的错误

解决办法:
select 后除了加上需要查询的字段之外,还要再加上order by 后面跟的字段

猜你喜欢

转载自blog.csdn.net/JAVA_LuZiMaKei/article/details/121927702