Description

Write a SQL query to find movies with odd id and description not 'boring'. Return all columns ordered by rating descending.

Table:cinema
ColumnType
idINT
movieTEXT
descriptionTEXT
ratingREAL

Examples

Input:CREATE TABLE cinema (id INT, movie TEXT, description TEXT, rating REAL); INSERT INTO cinema VALUES (1, 'Movie1', 'great', 8.5), (2, 'Movie2', 'boring', 9.0), (3, 'Movie3', 'boring', 7.0), (4, 'Movie4', 'fun', 8.8), (5, 'Movie5', 'great', 8.6);
Output:5|Movie5|great|8.6 1|Movie1|great|8.5
Explanation:

Odd IDs are 1, 3, 5. Movie3 has 'boring' description so it's excluded. Movies 1 and 5 qualify, ordered by rating descending: Movie5 (8.6), then Movie1 (8.5).

Input:CREATE TABLE cinema (id INT, movie TEXT, description TEXT, rating REAL); INSERT INTO cinema VALUES (2, 'Action Hero', 'exciting', 9.2), (4, 'Romance Story', 'boring', 6.5), (7, 'Sci-Fi Adventure', 'thrilling', 8.9), (9, 'Comedy Night', 'hilarious', 7.8), (11, 'Drama Series', 'boring', 8.1);
Output:7|Sci-Fi Adventure|thrilling|8.9 9|Comedy Night|hilarious|7.8
Explanation:

Movies with odd ids (7, 9, 11) are considered, but only id 7 and 9 have non-boring descriptions. Id 11 has 'boring' description so it's excluded. Results ordered by rating descending (8.9, then 7.8).

Input:CREATE TABLE cinema (id INT, movie TEXT, description TEXT, rating REAL); INSERT INTO cinema VALUES (1, 'Horror Film', 'scary', 6.2), (3, 'Documentary', 'educational', 7.5), (6, 'Musical', 'amazing', 9.1), (8, 'Thriller', 'boring', 8.3), (10, 'Animation', 'fun', 8.8);
Output:3|Documentary|educational|7.5 1|Horror Film|scary|6.2
Explanation:

Only movies with odd ids (1, 3) qualify since even ids (6, 8, 10) are excluded regardless of description. Both odd id movies have non-boring descriptions, so both are included and ordered by rating descending (7.5, then 6.2).

Constraints

  • Use MOD for odd check

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!