【LeetCode】620.有趣的電影
620.有趣的電影
某城市開了一家新的電影院,吸引了很多人過來看電影。該電影院特別注意使用者體驗,專門有個 LED顯示板做電影推薦,上面公佈著影評和相關電影描述。
作為該電影院的資訊部主管,您需要編寫一個 SQL查詢,找出所有影片描述為非boring
(不無聊)的並且id 為奇數的影片,結果請按等級rating
排列。
用到的表和資料SQL:
-- ---------------------------- -- Table structure for `cinema` -- ---------------------------- DROP TABLE IF EXISTS `cinema`; CREATE TABLE `cinema` ( `id`int(11) NOT NULL, `movie`varchar(255) DEFAULT NULL, `description` varchar(255) DEFAULT NULL, `rating` float(2,1) DEFAULT NULL, PRIMARYKEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- ---------------------------- -- Records of cinema -- ---------------------------- INSERT INTO `cinema` VALUES ('1', 'War', 'great3D', '8.9'); INSERT INTO `cinema` VALUES ('2', 'Science','fiction', '8.5'); INSERT INTO `cinema` VALUES ('3', 'irish','boring', '6.2'); INSERT INTO `cinema` VALUES ('4', 'Ice song','Fantacy', '8.6'); INSERT INTO `cinema` VALUES ('5', 'House card','Interesting', '9.1');
答案:
select * from cinema where description<> 'boring' and MOD(id, 2) = 1order by rating desc;
寫的比較粗糙,有不理解的可以掃描二維碼加QQ群找我解答。
相關推薦
【LeetCode】620.有趣的電影
620.有趣的電影某城市開了一家新的電影院,吸引了很多人過來看電影。該電影院特別注意使用者體驗,專門有個 LED顯示板做電影推薦,上面公佈著影評和相關電影描述。作為該電影院的資訊部主管,您需要編寫一個
【LeetCode】620.有趣的電影-學習筆記-MOD()函式的使用
某城市開了一家新的電影院,吸引了很多人過來看電影。該電影院特別注意使用者體驗,專門有個 LED顯示板做電影推薦,上面公佈著影評和相關電影描述。作為該電影院的資訊部主管,您需要編寫一個 SQL查詢,找出所有影片描述為非boring(不無聊)的並且id 為奇數的影片,結果請按等級
【leetcode】620. Not Boring Movies
97.66%(如果改為id%2=1則變為91.13% ,因此與python一樣,若是判斷範圍更大,則效率會更高)# Write your MySQL query statement below select id,movie,description,rating from c
【LeetCode】091. Decode Ways
rom size etc oss following nbsp pan ron ann 題目: A message containing letters from A-Z is being encoded to numbers using the following map
【LeetCode】040. Combination Sum II
log bsp for ont end ati 無法 clas class 題目: Given a collection of candidate numbers (C) and a target number (T), find all unique combinatio
【LeetCode】240. Search a 2D Matrix II
target ott arc rop win mat ive pty his 題目: Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the
【LeetCode】215. Kth Largest Element in an Array
distinct class ted ++ bsp order algo max git 題目: Find the kth largest element in an unsorted array. Note that it is the kth largest eleme
【LeetCode】169. Majority Element
turn end and else pear ive element emp bsp 題目: Given an array of size n, find the majority element. The majority element is the element t
【LeetCode】064. Minimum Path Sum
ive rom right ott path sum 處理 tom ber its 題目: Given a m x n grid filled with non-negative numbers, find a path from top left to bottom ri
【LeetCode】241. Different Ways to Add Parentheses
cto only leetcode save ++ ssi brush log ive 題目: Given a string of numbers and operators, return all possible results from computing all t
【LeetCode】039. Combination Sum
set sha leet delet als unique ati solution gin 題目: Given a set of candidate numbers (C) (without duplicates) and a target number (T), fin
【LeetCode】053. Maximum Subarray
子序列 fin n) cto largest nbsp code ray ive 題目: Find the contiguous subarray within an array (containing at least one number) which has the
【LeetCode】022. Generate Parentheses
ret logs int false return 題解 gen cto solution 題目: Given n pairs of parentheses, write a function to generate all combinations of well-for
【LeetCode】【Python】Binary Tree Inorder Traversal
nod 不知道 otto div ack return integer neu else Given a binary tree, return the inorder traversal of its nodes‘ values. For example: Gi
【BZOJ1444】[Jsoi2009]有趣的遊戲 AC自動機+概率DP+矩陣乘法
pri 註意 script aaaaa mil size borde tput char 【BZOJ1444】[Jsoi2009]有趣的遊戲 Description Input 註意 是0<=P Output Sample
【LeetCode】84. Largest Rectangle in Histogram——直方圖最大面積
the area 求解 技術分享 ges sent -s com col alt Given n non-negative integers representing the histogram‘s bar height where the width of each ba
【LeetCode】median of two sorted arrays
個數 i++ target 們的 data- 關於 arrays 推斷 get 題目:median of two sorted arrays 知識點:二分查找,中位數定義 public class Solution { /* * 關於:leetco
【Leetcode】137. Single Number II
val tar urn arr ber and mos calc cal 題目: Given an array of integers, every element appears three times except for one. Find that single o
【leetcode】Word Break(python)
條件 text for -m 是我 tex eas sso false 思路是這種。我們從第一個字符開始向後依次找,直到找到一個斷句的地方,使得當前獲得的子串在dict中,若找到最後都沒找到。那麽就是False了。 在找到第一個後,接下來找下一個斷句處,當然是從第
【leetcode】20. Valid Parentheses
lines fadein cti return nes string data- 復雜度 ack @requires_authorization @author johnsondu @create_time 2015.7.13 11:03 @url [v