[Swift]LeetCode620. 有趣的电影 | Not Boring Movies

[Swift]LeetCode620. 有趣的电影 | Not Boring Movies,第1张

概述SQL架构 1 Create table If Not Exists cinema (id int, movie varchar(255), description varchar(255), rating float(2, 1))2 Truncate table cinema3 insert into cinema (id, movie, description, rating) val

SQL架构

1 Create table If Not Exists cinema (ID int,movIE varchar(255),description varchar(255),rating float(2,1))2 Truncate table cinema3 insert into cinema (ID,movIE,description,rating) values (1,War,great 3D,8.9)4 insert into cinema (ID,rating) values (2,ScIEnce,fiction,8.5)5 insert into cinema (ID,rating) values (3,irish,boring,6.2)6 insert into cinema (ID,rating) values (4,Ice song,Fantacy,8.6)7 insert into cinema (ID,rating) values (5,House card,Interesting,9.1)

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:

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

某城市开了一家新的电影院,吸引了很多人过来看电影。该电影院特别注意用户体验,专门有个 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     |+---------+-----------+--------------+-----------+
108ms
1 # Write your MysqL query statement below2 select ID,rating 3 from cinema4 where mod(ID,2) = 1 AND description <> "boring"5 order by rating desc

109ms

1 # Write your MysqL query statement below2 select * from cinema where description != boring and  ID % 2 = 1 order by rating desc

110ms

1 # Write your MysqL query statement below2 select a.* from cinema as a where mod(a.ID,2)=1 and a.description != boring order by rating desc;

111ms

1 # Write your MysqL query statement below2 select *3 from cinema4 where not description = "boring" and mod(ID,2) = 1 5 order by rating desc

115ms

1 # Write your MysqL query statement below2 select * from cinema3 where ID%2 <> 0 4 and description not like "%boring%"5 order by rating desc
总结

以上是内存溢出为你收集整理的[Swift]LeetCode620. 有趣的电影 | Not Boring Movies全部内容,希望文章能够帮你解决[Swift]LeetCode620. 有趣的电影 | Not Boring Movies所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1019538.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存