运行此查询后,我得到的结果数量有问题:
SELECT g.genre_name,
count(distinct(d.director_id))
FROM genre g,
director d,
movie m
WHERE g.genre_id=m.genre_id
AND m.director_id=d.director_id;
表及其键是:
genre(genre_id, genre_name)
movie(genre_id, director_id)
director(director_id)
有人可以帮忙吗?提前谢谢!
答案 0 :(得分:0)
尝试添加GROUP BY
SELECT g.genre_name,
count(distinct(d.director_id))
FROM genre g,
director d,
movie m
WHERE g.genre_id=m.genre_id
AND m.director_id=d.director_id
GROUP BY g.genre_name;