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:

  1. +---------+-----------+--------------+-----------+
  2. | id | movie | description | rating |
  3. +---------+-----------+--------------+-----------+
  4. | 1 | War | great 3D | 8.9 |
  5. | 2 | Science | fiction | 8.5 |
  6. | 3 | irish | boring | 6.2 |
  7. | 4 | Ice song | Fantacy | 8.6 |
  8. | 5 | House card| Interesting| 9.1 |
  9. +---------+-----------+--------------+-----------+

For the example above, the output should be:

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

Code

  1. SELECT id, movie, description, rating FROM cinema WHERE mod(id,2) != 0 AND description != 'boring' ORDER BY rating DESC

[LeetCode] 620. Not Boring Movies_Easy tag: SQL的更多相关文章

  1. LeetCode - 620. Not Boring Movies

    X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a ...

  2. leetcode 620. Not Boring Movies 用where语句判断

    https://leetcode.com/problems/not-boring-movies/description/ 不管题目简不简单,现在先熟悉语法. 直接用where语句判断即可,判断奇偶可以 ...

  3. LeetCode: 620 Not Boring Movies(easy)

    题目: X city opened a new cinema, many people would like to go to this cinema. The cinema also gives o ...

  4. LeetCode 620. Not Boring Movies (有趣的电影)

    题目标签: 题目给了我们一个 cinema 表格, 让我们找出 不无聊的电影,并且id 是奇数的,降序排列. 比较直接简单的,具体看code. Java Solution: Runtime:  149 ...

  5. [LeetCode] 619. Biggest Single Number_Easy tag: SQL

    Table number contains many numbers in column num including duplicated ones.Can you write a SQL query ...

  6. [LeetCode] 176. Second Highest Salary_Easy tag: SQL

    Write a SQL query to get the second highest salary from the Employee table. +----+--------+ | Id | S ...

  7. [LeetCode] 196. Delete Duplicate Emails_Easy tag: SQL

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  8. [LeetCode] 584. Find Customer Referee_Easy tag: SQL

    Given a table customer holding customers information and the referee. +------+------+-----------+ | ...

  9. [LeetCode] 603. Consecutive Available Seats_Easy tag: SQL

    Several friends at a cinema ticket office would like to reserve consecutive available seats.Can you ...

随机推荐

  1. react-native 搭建环境

    1.安装 nodejs 配置环境变量 node -v npm -v 2.安装 javaSE 1.8以上 http://www.oracle.com/technetwork/java/javase/ar ...

  2. HTTP Error 400. The request hostname is invalid

    HTTP Error 400. The request hostname is invalid 错误, 检查服务的iis服务得知,是因为在绑定主机和端口的那一步时也指定了相应的域名. 解决办法: 去掉 ...

  3. css学习_标签的显示模式

    标签的显示模式 a.块级元素(最典型的是  div标签) 特点: 默认宽度  100% 可以容纳块级元素和内联元素 b.行内元素 (最典型的是  span标签) 特点: c.行内块元素(最典型的是 i ...

  4. [No0000C9]神秘的掐指一算是什么?教教你也会

    很多朋友看到传说中诸葛亮以及那些聪明人掐指一算,惊叹不已.那些人以“察天地之理.通鬼神之志”,每次占卜时,做一大堆的神秘仪式,然后掐指一算,便大有“乾坤尽收在手”的感觉.在普通人眼里,他们的手神秘异常 ...

  5. C语言保证,0永远不是有效的数据地址,因此,返回址0可用来表示发生的异常事件

    C语言保证,0永远不是有效的数据地址,因此,返回址0可用来表示发生的异常事件

  6. Java8 in action

    解决的问题: behavior parameterization,即可以把一段code,逻辑作为参数传入: 这样做的目的,当然为了代码抽象和重用,把变化的逻辑抽象出去: 在java中,如果要实现beh ...

  7. oracle优化:避免全表扫描

    http://blog.csdn.net/onetree2010/article/details/6098259

  8. NPM升级

    nmp的更新可以使用自身指令即可: npm install npm -g 可以看到从3.10.10升级到了4.0.5 都说npm比node升级的快,现在比起来nodejs的更新速度更快 如果npm官方 ...

  9. IntelliJ常用设置及快捷键

    转自: http://www.blogjava.net/rockblue1988/archive/2014/10/25/418994.html 一.黑色主题 Darcula眼睛舒服,最重要的是酷!设置 ...

  10. oracle按照指定列排序操作

    按照...分组排序后,得到行编号: row_number() over(partition by ... order by ...) 按照...分组排序后,得到相应的列的第一个数据: first_va ...