0

我正在尝试获得数据库中电影的最低平均评分。

目前我有:

select movie.movietitle as "Lowest Average Rating"
from movie, rating 
where movie.movieid = rating.movieid
group by movie.movietitle
having avg(rating.rating) = min(avg(rating.rating));

但我收到错误“组函数嵌套太深”。谁能为我提供正确的方法并解释为什么这不起作用?

谢谢

4

1 回答 1

1
SELECT MOVIETITLE AS "Movie Title", AVG(RATING) AS "Lowest Average Rating"
FROM MOVIE, RATING
WHERE MOVIE.MOVIEID = RATING.MOVIEID
GROUP BY MOVIETITLE
HAVING AVG(RATING) =
(
    SELECT MIN(AVG(RATING)) AS "AVGRating"
    FROM MOVIE, RATING
    WHERE MOVIE.MOVIEID = RATING.MOVIEID
    GROUP BY MOVIETITLE
)
于 2012-11-20T02:28:42.367 回答