Writing queries task #13

<PLEASE USE THIS TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/en/courses/learn-sql/projects/learn_sql_query_table

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
I don’t understand the task. Normal code will return 10 action movies.
<In this course, it often helps to include a screenshot of your whole web browser – that lets everyone see what you see. If you wish to include a screenshot, add it below this line.>

<If you wish to copy/paste in your code, you can use this next section. This will allow others to copy/paste your code for testing – something that they won’t be able to do with just a screenshot.>

```

select * from movies
where imdb_rating > 8
order by genre asc
limit 10;

<do not remove the three backticks above>

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

The only columns we need are, name, genre and imdb_rating.

Give this a try…

SELECT name, genre, imdb_rating FROM movies
WHERE imdb_rating > 8
ORDER by 2
LIMIT 10;

Can you please explain why you’ve used “ORDER BY 2”? And this code gives me the same result i.e. list of 10 action movies.

There will three columns in the report. Sort order will determined by the second column.

1 Like