Question

I have 3 tables : enter image description here

Film.rating is the average of ratings for that film from the Rate table. In SQL, to calculate film rating I would do:

SELECT AVG(Rate.rating)
FROM Rate, Film
WHERE Rate.uidFilm=Film.uidFilm;

I do not know how to write this in MS Access and where I should put this (or maybe another?) formula?

How do I 'connect' Film.rating with the calculation above? In constructor for the Film table?

Was it helpful?

Solution

You need a GROUP BY in your query. Try this

SELECT Film.Title, AVG(Rate.rating)
FROM Rate
    INNER JOIN Film ON Rate.uidFilm = Film.uidFilm
GROUP BY Film.Title;

This should give you the average ratings of all movies with their title.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top