我使用查询
在hive中创建了一个表CREATE TABLE u_data (
userid INT,
movieid INT,
rating INT,
unixtime STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
STORED AS TEXTFILE;
然后将一些数据加载到其中,现在我想检索具有超过30个评级的电影的平均评分。
我尝试使用查询创建视图:
create view ratingcount as select movieid, count(rating) as num_of_ratings from u_data group by movieid;
然后使用连接查询:
Select movieid, avg(rating) from u_data join ratingcount on u_data.movieid = ratingcount .movieid where num_of_ratings >30;
给予例外。请让我知道如何检索所需的数据?
答案 0 :(得分:0)
试试这个,
Select movieid, avg(rating) from u_data group by movieid having count(rating) > 30;