题目
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 | +---------+-----------+--------------+-----------+
algorithm
we can use the mod(id,2)=1 to determine the odd id, and then add a description != 'boring' should address this problem.
mysql
select * from cinema where mod(id, 2) = 1 and description != 'boring' order by rating desc ;
如对本文有疑问, 点击进行留言回复!!
MySQL-关系代数-并、交、差、等值连接、自然连接、左连接。。。
【MySQL牛客】10.获取所有非manager的员工emp_no
网友评论