Hive 报错 Invalid column reference 列名

时间:2024-10-27 08:01:06

两张表

 

当我执行

select ,,substr(,-5,4) as years,avg() as avgScore
FROM t_movie as m join t_rating as r on  =  
GROUP by 
HAVING avgScore >= 4;

报错:

Invalid column reference 'moviename'

 

改成下,就好了

select ,,substr(,-5,4) as years,avg() as avgScore
FROM t_movie as m join t_rating as r on  =  
GROUP by ,
HAVING avgScore >= 4;

 

我理解为,t_movie 表的 userid 与 moviename 两字段都是唯一的,所以分组的时候要一起写