Writing Queries Task #13


#1

Hi, I didn't quite get what the task #13 is about.

task #13 : Return 10 movies with an IMDb rating greater than 8 sorted by their genre.

So I begin writing:

SELECT * FROM movies
WHERE imdb_rating > 8
ORDER BY genre ASC
LIMIT 10;

I noticed all of the 10 movies were action. :open_mouth:?

Was this task intended to have 10 movies for each genre?
If so, how?

Thank you. :relaxed:


#2

@hiyopura,
The re-formulated request would be
"limit 10" per genre ( which is per group-by genre )

Be aware that you are using SQLITE
and read a discussion
http://stackoverflow.com/questions/751399/sql-query-how-to-apply-limit-within-group-by


#3

If you order by ASC(ascending) then "Action" alphabetically should be there as it starts with "Ac".


#4

@leonhard.wettengmx.n

Thank you, now I got what #13 means.
Though I got confused with the link you gave me,
I guess I'm too new to SQL to understand it. :confused:


#5

I am not sure what i have to do here:

SELECT * FROM movies WHERE imdb_rating > 8 AND genre LIMIT 10;

#6

Return 10 movies with an IMDb rating greater than 8 sorted by their genre.

I input:

SELECT * FROM movies
WHERE imdb_rating > 8
ORDER BY genre ASC
LIMIT 10;

Gives me only 10 first action genres.. How would I do this to allow limit 10 for each genre? Leonhard.wettengmx.n's response doesnt really make sense.

I even tried
SELECT * FROM movies
WHERE imdb_rating > 9
ORDER BY genre ASC
LIMIT 10;

And I get back an error.
Please someone assist on explaining.


#7

when i switch the rating to 8.5 it seems to do the trick.