本文介绍: hql如下select length(tag) from table1 order by length(tag) limit 20;报错FAILED: SemanticException [Error 10004]: Line…Invalid table alias or column reference ‘tag’: (possible column names are: _c0)FAILED: SemanticException [Error 10004]: Line…Invalid table

hql如下
select length(tag) from table1 order by length(tag) limit 20;
报错FAILED: SemanticException [Error 10004]: Line…Invalid table alias or column reference ‘tag’: (possible column names are: _c0)

FAILED: SemanticException [Error 10004]: Line…Invalid table alias or column reference ‘tag’: (possible column names are: _c0)

修改
用别名替代length(tag), 如下
select length(tag) as taglen from table1 order by taglen limit 20;

order by中可以使用普通函数(如to_date()),但是不能使用聚合函数(如count(), sum())。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注