Ratingshive
表在Genre
上动态分区,并且该表包含movie_titles
和rating of movies
select 100 * stars / total
from (select count(rating) as stars
from ratingshive
where rating = 5) t1,
(select count(1) as total
from ratingshive) t2
在Hive中运行上述查询时,出现此错误-
FAILED: ParseException line 1:100 missing EOF at ',' near 't1'
答案 0 :(得分:0)
Hive最不喜欢您的查询,因为它是旧版本。但是,您无需两次查询相同的ratingshive
表,然后交叉连接标量结果。将聚合与case
一起使用:
select 100 * count(case when rating=5 then 1 end)/count(*) as rating_percent
from ratingshive;