0

I'm stuck on pset7 10.sql, it keeps coming up with a misuse of aggregate function. My code is currently:

SELECT name FROM people INNER JOIN directors ON people.id = directors.person_id INNER JOIN ratings ON directors.movie_id = ratings.movie_id WHERE AVG(rating) >= 9.0

As the solution only asks for one column, I thought this would be the right way of doing it?

Thanks in advance

1
  • Begs the question: Why use AVG? The spec asks for "a movie that received a rating of at least 9.0". Each movie is independent of any others. Here is the sqlite3 doc on aggregate functions FYI. Commented Jun 1, 2020 at 11:58

1 Answer 1

1

Your AVG is not required. Please also note your catching duplicates (different people with same name). I think what have at the back of your mind is something like this:

SELECT name FROM
(SELECT DISTINCT id, name FROM people INNER JOIN directors ON people.id = directors.person_id INNER JOIN ratings ON directors.movie_id = ratings.movie_id WHERE rating >= 9.0)
1
  • Thanks - this has now been solve. Thanks for your help!
    – s1401988
    Commented Jun 15, 2020 at 21:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .