Not Boring Movies - Problem
Given a table Cinema that contains information about movies including their ID, name, description, and rating.
Write a SQL query to find all movies that meet both of these criteria:
- The movie has an odd-numbered ID
- The movie's description is not "boring"
Return the results ordered by rating in descending order.
Table Schema
Cinema
| Column Name | Type | Description |
|---|---|---|
id
PK
|
int | Primary key - unique movie identifier |
movie
|
varchar | Name of the movie |
description
|
varchar | Genre or description of the movie |
rating
|
float | Movie rating between 0.00 and 10.00 |
Primary Key: id
Note: Each row represents a movie with its details and rating
Input & Output
Example 1 — Mixed Movies
Input Table:
| id | movie | description | rating |
|---|---|---|---|
| 1 | War | great 3D | 8.9 |
| 2 | Science | fiction | 8.5 |
| 3 | irish | boring | 6.2 |
| 4 | Ice song | Fantacy | 8.6 |
| 5 | House card | Interesting | 9.1 |
Output:
| id | movie | description | rating |
|---|---|---|---|
| 5 | House card | Interesting | 9.1 |
| 1 | War | great 3D | 8.9 |
💡 Note:
Movies with IDs 1 and 5 have odd IDs and descriptions that are not 'boring'. ID 2 and 4 are even (excluded), ID 3 has 'boring' description (excluded). Results are sorted by rating descending: 9.1, then 8.9.
Example 2 — All Boring or Even IDs
Input Table:
| id | movie | description | rating |
|---|---|---|---|
| 2 | Action | thrilling | 7.5 |
| 4 | Comedy | funny | 8 |
| 7 | Drama | boring | 9.5 |
Output:
| id | movie | description | rating |
|---|
💡 Note:
No movies meet both criteria. IDs 2 and 4 are even numbers (excluded), and ID 7 has 'boring' description (excluded). Result is empty.
Example 3 — Single Valid Movie
Input Table:
| id | movie | description | rating |
|---|---|---|---|
| 9 | Thriller | suspense | 7.8 |
Output:
| id | movie | description | rating |
|---|---|---|---|
| 9 | Thriller | suspense | 7.8 |
💡 Note:
Movie with ID 9 has an odd ID and description is not 'boring', so it's included in the result.
Constraints
-
1 ≤ id ≤ 1000 -
ratingis a float with 2 decimal places in range[0, 10] -
movieanddescriptionare varchar strings
Visualization
Tap to expand
Understanding the Visualization
1
Input
Cinema table with all movies
2
Filter
WHERE conditions remove unwanted rows
3
Sort
ORDER BY rating DESC
Key Takeaway
🎯 Key Insight: Use WHERE with multiple conditions and ORDER BY to filter and sort data in a single query
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code