查找其粉丝少于该特定类型的平均粉丝数量的电影
fan (fID: integer, fName: string)
movies(mID: integer, mName: string, mGenre: string, mYear: integer)
like(fID: integer, mID: integer)
外键:
(like.fID -> fan.fID)
(like.mID-.> movie.mID)
我尝试这样做以获得每部电影的平均粉丝数量,但没有奏效:
SELECT mGenre, AVG(total)
FROM findAverage, movies
GROUP BY mGenre;
CREATE VIEW findAverage AS
SELECT m.mName, COUNT(DISTINCT L.fID) as total
FROM like L, movies m
WHERE L.mID = B.mID
GROUP BY m.mName