0
点赞
收藏
分享

微信扫一扫

LeetCode MySQL刷题——day2


目录

​​一、上升的温度​​

​​1、题目描述​​

​​2、题解​​

​​ 3、源码​​

​​二、大的国家​​

​​1、题目描述​​

​​2、题解​​

​​ 3、源码​​

​​ 三、超过五名学生的课​​

​​1、题目描述​​

​​2、题解 ​​

​​3、源码​​

​​ 四、有趣的电影​​

​​1、题目描述​​

​​2、题解​​

​​3、源码​​

​​ 五、变更性别​​

​​1、题目描述​​

​​ 2、题解​​

​​3、源码​​

一、上升的温度

1、题目描述

LeetCode MySQL刷题——day2_leetcode

 

LeetCode MySQL刷题——day2_leetcode_02

2、题解

LeetCode MySQL刷题——day2_mysql_03

 3、源码

# Write your MySQL query statement below
select
e1.id
from Weather as e1 inner join Weather as e2 on
DATEDIFF(e1.recordDate,e2.recordDate) = 1 and e1.Temperature > e2.Temperature;

二、大的国家

1、题目描述

LeetCode MySQL刷题——day2_leetcode_04

LeetCode MySQL刷题——day2_mysql_05

 

2、题解

 3、源码

# Write your MySQL query statement below
select
name,population,area
from World
where area >= 3000000 or population >= 25000000;

 三、超过五名学生的课

1、题目描述

LeetCode MySQL刷题——day2_蓝桥杯_06

2、题解 

LeetCode MySQL刷题——day2_leetcode_07

3、源码

# Write your MySQL query statement below
select
class
from
courses
GROUP BY class
HAVING COUNT(student) >=5;


# SELECT
# class
# FROM
# (SELECT
# class, COUNT(DISTINCT student) AS num
# FROM
# courses
# GROUP BY class) AS temp_table
# WHERE
# num >= 5
# ;

 四、有趣的电影

1、题目描述

LeetCode MySQL刷题——day2_蓝桥杯_08

 

2、题解

LeetCode MySQL刷题——day2_mysql_09

3、源码

select 
id,movie,description,rating
from
cinema
where mod(id,2) = 1 and description != 'boring'
order by rating desc;

 五、变更性别

1、题目描述

LeetCode MySQL刷题——day2_蓝桥杯_10

 

LeetCode MySQL刷题——day2_蓝桥杯_11

 2、题解

LeetCode MySQL刷题——day2_mysql_12

3、源码

# Write your MySQL query statement below
update Salary
SET
sex = CASE sex
WHEN 'm' THEN 'f'
ELSE 'm'
END;

 

举报

相关推荐

0 条评论