{"id":2012,"date":"2018-03-07T01:28:07","date_gmt":"2018-03-07T09:28:07","guid":{"rendered":"http:\/\/zxi.mytechroad.com\/blog\/?p=2012"},"modified":"2018-03-07T23:50:50","modified_gmt":"2018-03-08T07:50:50","slug":"leetcode-620-not-boring-movies","status":"publish","type":"post","link":"https:\/\/zxi.mytechroad.com\/blog\/sql\/leetcode-620-not-boring-movies\/","title":{"rendered":"\u82b1\u82b1\u9171 LeetCode 620. Not Boring Movies"},"content":{"rendered":"<p><strong>Problem:<\/strong><\/p>\n<p><a href=\"https:\/\/leetcode.com\/problems\/not-boring-movies\/description\/\">https:\/\/leetcode.com\/problems\/not-boring-movies\/description\/<\/a><\/p>\n<p>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\u2019 ratings and descriptions.<\/p>\n<p>Please write a SQL query to output movies with an odd numbered ID and a description that is not &#8216;boring&#8217;. Order the result by rating.<\/p>\n<p>For example, table\u00a0<code>cinema<\/code>:<\/p>\n<pre>+---------+-----------+--------------+-----------+\r\n|   id    | movie     |  description |  rating   |\r\n+---------+-----------+--------------+-----------+\r\n|   1     | War       |   great 3D   |   8.9     |\r\n|   2     | Science   |   fiction    |   8.5     |\r\n|   3     | irish     |   boring     |   6.2     |\r\n|   4     | Ice song  |   Fantacy    |   8.6     |\r\n|   5     | House card|   Interesting|   9.1     |\r\n+---------+-----------+--------------+-----------+\r\n<\/pre>\n<p>For the example above, the output should be:<\/p>\n<pre class=\"\">+---------+-----------+--------------+-----------+\r\n|   id    | movie     |  description |  rating   |\r\n+---------+-----------+--------------+-----------+\r\n|   5     | House card|   Interesting|   9.1     |\r\n|   1     | War       |   great 3D   |   8.9     |\r\n+---------+-----------+--------------+-----------+<\/pre>\n<p>MySQL<\/p>\n<pre class=\"lang:mysql decode:true \"># Author: Huahua\r\nSELECT * FROM cinema \r\nWHERE id % 2 = 1 \r\nAND description != 'boring' \r\nORDER BY rating DESC<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Problem: https:\/\/leetcode.com\/problems\/not-boring-movies\/description\/ X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[238],"tags":[222,242],"class_list":["post-2012","post","type-post","status-publish","format-standard","hentry","category-sql","tag-easy","tag-sql","entry","simple"],"_links":{"self":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/2012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/comments?post=2012"}],"version-history":[{"count":2,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/2012\/revisions"}],"predecessor-version":[{"id":2014,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/posts\/2012\/revisions\/2014"}],"wp:attachment":[{"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/media?parent=2012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/categories?post=2012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zxi.mytechroad.com\/blog\/wp-json\/wp\/v2\/tags?post=2012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}