Not Boring Movies
Problem
Cinema(id, movie, description, rating). Return rows where id is odd and description != 'boring', ordered by rating desc.
c=[(1,'War','great',8.9),(2,'Science','fiction',8.5),(3,'Irish','boring',6.2),(5,'House','interesting',9.1)][(5,'House','interesting',9.1),(1,'War','great',8.9)]SELECT *
FROM cinema
WHERE id % 2 = 1 AND description <> 'boring'
ORDER BY rating DESC;
Explanation
This is a straightforward filter and sort query — there is no clever data structure, just the right conditions written in the WHERE and ORDER BY clauses.
The WHERE applies two conditions joined by AND, so a row must satisfy both to be kept. id % 2 = 1 keeps rows with an odd id (the remainder after dividing by 2 is 1), and description <> 'boring' drops any movie whose description is exactly "boring".
Finally ORDER BY rating DESC sorts the surviving rows from highest rating to lowest, so the best-rated movie appears first.
Example: from War (id 1, great), Science (id 2, fiction), Irish (id 3, boring), House (id 5, interesting), Science is dropped for having an even id and Irish is dropped for being boring. War and House remain, and sorting by rating puts House (9.1) above War (8.9).