Skip to main content
deleted 7 characters in body
Source Link

On the Pset page it says that the solution must have 3392 rows. I wrote two different solutions, both accepted by check50, with different number of rows.

The first one gives 3389 lines:

SELECT COUNT(DISTINCT name) FROM people
JOIN directors ON directors.person_id = people.id
JOIN movies ON movies.id  = directors.movie_id
JOIN ratings ON ratings.movie_id = movies.id
WHERE ratings.rating >= 9.0;

The second one gives 3392 lines:

SELECT name FROM people WHERE id IN
(SELECT person_id FROM directors WHERE MOVIE_ID IN
(SELECT movie_id FROM ratings WHERE rating >= 9.0));

Any idea on why they are both accepted and why they give different results?

On the Pset page it says that the solution must have 3392 rows. I wrote two different solutions, both accepted by check50, with different number of rows.

The first one gives 3389 lines:

SELECT COUNT(DISTINCT name) FROM people
JOIN directors ON directors.person_id = people.id
JOIN movies ON movies.id  = directors.movie_id
JOIN ratings ON ratings.movie_id = movies.id
WHERE ratings.rating >= 9.0;

The second one gives 3392 lines:

SELECT name FROM people WHERE id IN
(SELECT person_id FROM directors WHERE MOVIE_ID IN
(SELECT movie_id FROM ratings WHERE rating >= 9.0));

Any idea on why they are both accepted and why they give different results?

On the Pset page it says that the solution must have 3392 rows. I wrote two different solutions, both accepted by check50, with different number of rows.

The first one gives 3389 lines:

SELECT DISTINCT name FROM people
JOIN directors ON directors.person_id = people.id
JOIN movies ON movies.id  = directors.movie_id
JOIN ratings ON ratings.movie_id = movies.id
WHERE ratings.rating >= 9.0;

The second one gives 3392 lines:

SELECT name FROM people WHERE id IN
(SELECT person_id FROM directors WHERE MOVIE_ID IN
(SELECT movie_id FROM ratings WHERE rating >= 9.0));

Any idea on why they are both accepted and why they give different results?

Source Link

cs50x Ps7 Movies 10.sql

On the Pset page it says that the solution must have 3392 rows. I wrote two different solutions, both accepted by check50, with different number of rows.

The first one gives 3389 lines:

SELECT COUNT(DISTINCT name) FROM people
JOIN directors ON directors.person_id = people.id
JOIN movies ON movies.id  = directors.movie_id
JOIN ratings ON ratings.movie_id = movies.id
WHERE ratings.rating >= 9.0;

The second one gives 3392 lines:

SELECT name FROM people WHERE id IN
(SELECT person_id FROM directors WHERE MOVIE_ID IN
(SELECT movie_id FROM ratings WHERE rating >= 9.0));

Any idea on why they are both accepted and why they give different results?