1. 题目描述:

某城市开了一家新的电影院,吸引了很多人过来看电影。该电影院特别注意用户体验,专门有个 LED显示板做电影推荐,上面公布着影评和相关电影描述。

作为该电影院的信息部主管,您需要编写一个 SQL查询,找出所有影片描述为非 boring (不无聊) 的并且 id 为奇数 的影片,结果请按等级 rating 排列。

 

例如,下表 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     |
+---------+-----------+--------------+-----------+
对于上面的例子,则正确的输出是为:

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

 

2.提交代码:

# Write your MySQL query statement below
select * from cinema where id%2 = 1 and description != 'boring' order by rating desc;

 

 

3.性能:  关于性能问题,同样的 sql 时间也是不一样的,所以,我觉得在深夜或者 早晨提交的 时候,服务器压力小,时间会短

【LeetCode_mysql】620. 有趣的电影

 

4....

 

 

相关文章:

  • 2021-09-11
  • 2021-10-16
  • 2021-10-31
  • 2021-12-04
  • 2022-01-13
  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-25
  • 2021-07-24
  • 2021-10-03
  • 2022-12-23
  • 2021-11-14
  • 2021-08-27
相关资源
相似解决方案