Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- o.name, AVG(r.rating) AS cnt
- FROM
- ratings r
- JOIN
- genres_movies g ON r.movie_id = g.movie_id
- JOIN
- users u ON r.user_id = u.id
- JOIN
- occupations o ON u.occupation_id = o.id
- WHERE
- g.id = 11
- AND o.name IN (SELECT
- o.name
- FROM
- ratings r
- JOIN
- users u ON r.user_id = u.id
- JOIN
- occupations o ON u.occupation_id = o.id
- GROUP BY o.name
- HAVING COUNT(r.user_id) > 3)
- GROUP BY u.occupation_id
- ORDER BY cnt DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement