[LeetCode] 620.Not Boring Movies
[LeetCode] 620.Not Boring Movies
- 題目描述
- 解題思路
- 實驗代碼
題目描述
X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions.
Please write a SQL query to output movies with an odd numbered ID and a description that is not ‘boring’. Order the result by rating.
For example, table cinema:
| 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 |
For the example above, the output should be:
| 5 | House card | Interesting | 9.1 |
| 1 | War | great 3D | 8.9 |
解題思路
SQL第三彈,說實話博主不怎么清楚SQL具體語句,去年學過的數據庫方面的知識忘得差不多了哈哈哈。所以不知道寫出來是否符合標準,不過確實是AC了,憑回憶寫的。這道題注意三個條件:
1. 選擇出來的id要為奇數; (id % 2 = 1)
2. description不能為boring; (description <> ‘boring’)
3. 選擇出來的數據按rating倒序排序。 (ORDER BY rating DESC)
具體見代碼。
實驗代碼
# Write your MySQL query statement below SELECT * FROM cinema WHERE (description <> 'boring') AND (id % 2 = 1) ORDER BY rating DESC總結
以上是生活随笔為你收集整理的[LeetCode] 620.Not Boring Movies的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Docker 安全问题与防护 (学习笔记
- 下一篇: 重点!!!计算虚拟化技术(HCIE云方向