getting aggregate functions then using them

时间:2015-12-14 18:03:14

标签: database ms-access

im probably gonna have difficulty explaining my exact problem but im using an aggregate function to get the average rating of movies but then i dont know how to use that and then list the movies which have a rating less than that i have tried this with a union query first and this didnt work so now im trying it with an implicit join and this is what i have:

SELECT
FROM MOVIE
WHERE RATING = (SELECT AVG (RATING) AS avg_rating
                FROM MOVIE
                WHERE RATING = (SELECT RATING 
                                FROM MOVIE
                                WHERE RATING < avg_rating));

i just seem to be going in circles here thanks in advance!

1 个答案:

答案 0 :(得分:1)

这是我在Access中所做的:

SELECT *
FROM MOVIE
WHERE (((MOVIE.[RATING])<(SELECT AVG (RATING) AS avg_rating from Movie)));