![[Swift]LeetCode620. 有趣的电影](/uploads/image/0436.jpg)
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
➤微信公众号:山青咏芝(shanqingyongzhi)
➤博客园地址:山青咏芝(/)
➤GitHub地址:
➤原文地址:.html
➤如果链接不是山青咏芝的博客园地址,则可能是爬取作者的文章。
➤原文已修改更新!强烈建议点击原文地址阅读!支持作者!支持原创!
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
SQL架构
1 Create table If Not Exists cinema (id int, movie varchar(255), description varchar(255), rating float(2, 1))
2 Truncate table cinema
3 insert into cinema (id, movie, description, rating) values ('1', 'War', 'great 3D', '8.9')
4 insert into cinema (id, movie, description, rating) values ('2', 'Science', 'fiction', '8.5')
5 insert into cinema (id, movie, description, rating) values ('3', 'irish', 'boring', '6.2')
6 insert into cinema (id, movie, description, rating) values ('4', 'Ice song', 'Fantacy', '8.6')
7 insert into cinema (id, movie, description, 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 below 2 select id, movie, description, rating 3 from cinema 4 where mod(id,2) = 1 AND description <> "boring" 5 order by rating desc
109ms
1 # Write your MySQL query statement below 2 select * from cinema where description != 'boring' and id % 2 = 1 order by rating desc
110ms
1 # Write your MySQL query statement below 2 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 below 2 select * 3 from cinema 4 where not description = "boring" and mod(id, 2) = 1 5 order by rating desc
115ms
1 # Write your MySQL query statement below 2 select * from cinema 3 where id%2 <> 0 4 and description not like "%boring%" 5 order by rating desc
转载于:.html
本文发布于:2024-03-05 00:46:39,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/1709616007120768.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
| 留言与评论(共有 0 条评论) |