Skip to content

Commit c9a5f82

Browse files
committed
[LeetCode Sync] Runtime - 217 ms (88.03%), Memory - 0.0B (100.00%)
1 parent 4d9139e commit c9a5f82

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<p>Table: <code>Cinema</code></p>
2+
3+
<pre>
4+
+----------------+----------+
5+
| Column Name | Type |
6+
+----------------+----------+
7+
| id | int |
8+
| movie | varchar |
9+
| description | varchar |
10+
| rating | float |
11+
+----------------+----------+
12+
id is the primary key (column with unique values) for this table.
13+
Each row contains information about the name of a movie, its genre, and its rating.
14+
rating is a 2 decimal places float in the range [0, 10]
15+
</pre>
16+
17+
<p>&nbsp;</p>
18+
19+
<p>Write a solution to report the movies with an odd-numbered ID and a description that is not <code>&quot;boring&quot;</code>.</p>
20+
21+
<p>Return the result table ordered by <code>rating</code> <strong>in descending order</strong>.</p>
22+
23+
<p>The&nbsp;result format is in the following example.</p>
24+
25+
<p>&nbsp;</p>
26+
<p><strong class="example">Example 1:</strong></p>
27+
28+
<pre>
29+
<strong>Input:</strong>
30+
Cinema table:
31+
+----+------------+-------------+--------+
32+
| id | movie | description | rating |
33+
+----+------------+-------------+--------+
34+
| 1 | War | great 3D | 8.9 |
35+
| 2 | Science | fiction | 8.5 |
36+
| 3 | irish | boring | 6.2 |
37+
| 4 | Ice song | Fantacy | 8.6 |
38+
| 5 | House card | Interesting | 9.1 |
39+
+----+------------+-------------+--------+
40+
<strong>Output:</strong>
41+
+----+------------+-------------+--------+
42+
| id | movie | description | rating |
43+
+----+------------+-------------+--------+
44+
| 5 | House card | Interesting | 9.1 |
45+
| 1 | War | great 3D | 8.9 |
46+
+----+------------+-------------+--------+
47+
<strong>Explanation:</strong>
48+
We have three movies with odd-numbered IDs: 1, 3, and 5. The movie with ID = 3 is boring so we do not include it in the answer.
49+
</pre>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SELECT *
2+
FROM Cinema
3+
WHERE MOD(id, 2) = 1 and description != "boring"
4+
ORDER BY rating DESC

0 commit comments

Comments
 (0)