第三题:Not Boring Movies

https://leetcode.com/problems/not-boring-movies/description/

X市开了一家新电影院,很多人都想去这家电影院。电影院还会发布一张海报,说明电影的评级和描述。

请编写一个SQL查询来输出具有奇数编号ID和非“无聊”描述的电影。按评级订购结果。

For example, table cinema:

+---------+-----------+--------------+-----------+
|   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     |
+---------+-----------+--------------+-----------+

For the example above, the output should be:

+---------+-----------+--------------+-----------+
|   id    | movie     |  description |  rating   |
+---------+-----------+--------------+-----------+
|   5     | House card|   Interesting|   9.1     |
|   1     | War       |   great 3D   |   8.9     |
+---------+-----------+--------------+-----------+

 

SELECT * FROM cinema
WHERE id % 2 = 1
AND description != "boring"
ORDER BY rating DESC;

 

posted @ 2019-02-25 10:27  小林子奋斗的点滴  阅读(122)  评论(0编辑  收藏  举报