我目前正试图找到所有人的名字谁导演的电影,收到了至少9.0的评级方案,这些表是
CREATE TABLE movies (
id INTEGER,
title TEXT NOT NULL,
year NUMERIC,
PRIMARY KEY(id)
);
CREATE TABLE stars (
movie_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
FOREIGN KEY(movie_id) REFERENCES movies(id),
FOREIGN KEY(person_id) REFERENCES people(id)
);
CREATE TABLE directors (
movie_id INTEGER NOT NULL,
person_id INTEGER NOT NULL,
FOREIGN KEY(movie_id) REFERENCES movies(id),
FOREIGN KEY(person_id) REFERENCES people(id)
);
CREATE TABLE ratings (
movie_id INTEGER NOT NULL,
rating REAL NOT NULL,
votes INTEGER NOT NULL,
FOREIGN KEY(movie_id) REFERENCES movies(id)
);
CREATE TABLE people (
id INTEGER,
name TEXT NOT NULL,
birth NUMERIC,
PRIMARY KEY(id)
);
我的SQL查询是:
SELECT DISTINCT name FROM people
WHERE id IN ( SELECT person_id FROM directors WHERE movie_id IN (
SELECT id FROM movies WHERE id IN (
SELECT movie_id FROM ratings WHERE votes >= 9.0)));
然而,这使check50测试失败,并且给出不正确的输出。谁能帮我看看我哪里做错了?
2条答案
按热度按时间rsaldnfx1#
说明书上说(强调部分由作者补充)
在
10.sql
中,编写一个SQL查询,列出所有执导过评分至少为9.0的电影的人的姓名。查询不对
ratings.rating
列进行筛选。yzxexxkh2#
试试这个: