美文网首页
lettcode sql

lettcode sql

作者: hehehehe | 来源:发表于2022-03-18 11:58 被阅读0次
update salary 
       set sex = case sex
       when 'm' then 'f'
       else 'm'
end;

+----+-------+--------+-----------+
| Id | Name | Salary | ManagerId |
+----+-------+--------+-----------+
| 1 | Joe | 70000 | 3 |
| 2 | Henry | 80000 | 4 |
| 3 | Sam | 60000 | NULL |
| 4 | Max | 90000 | NULL |
+----+-------+--------+-----------+

select a.Name as Employee
from Employee as a inner join Employee as b
on a.ManagerId = b.Id
where a.Salary > b.Salary

+----+------------------+
| Id | Email |
+----+------------------+
| 1 | john@example.com |
| 2 | bob@example.com |
| 3 | john@example.com |
+----+------------------+

DELETE p1
FROM Person p1 inner join Person p2
on p1.Email = p2.Email AND p1.Id > p2.Id

+---------+------------+------------------+
| Id(INT) | Date(DATE) | Temperature(INT) |
+---------+------------+------------------+
| 1 | 2015-01-01 | 10 |
| 2 | 2015-01-02 | 25 |
| 3 | 2015-01-03 | 20 |
| 4 | 2015-01-04 | 30 |
+---------+------------+------------------+
+----+
| Id |
+----+
| 2 |
| 4 |
+----+

select a.Id
from Weather as a inner join Weather as b
on datediff(a.Date,b.Date) = 1 and a.Temperature > b.Temperature
select class
from courses
group by class
having count(distinct student) >= 5

相关文章

  • lettcode sql

    +----+-------+--------+-----------+| Id | Name | Salary ...

  • lettcode 题目

    Valid Parentheses给定一个只包括'(',')','{','}','[',']'的字符串,判断字符串...

  • lettcode题目

    https://www.cnblogs.com/yuzhangcmu/tag/LeetCode/

  • 最长公共前缀 和 最大水量

    lettcode 题目求解 Python Longest Common Prefix给定一个字符串,返回其最长前缀...

  • Lettcode 数组题

    Summary Ranges 找到连续的值,使用一个格式将其打印出来。 来自讨论区 StefanPochmann ...

  • Lettcode 动态规划 medium

    Unique Paths II (Lettcode)一个机器人在 M * N 的二维数组中,机器人可以向下或向右移...

  • lettcode 动态规划 easy

    House Robber一个数组中找出子数组和最大的和,要求数组中的数字不能连续出现。例如 [1, 2, 3, 1...

  • lettcode刷题之贪心

    leetcode刷题,使用python 1, 跳跃游戏 II —— 0045 贪心算法给定一个长度为 n 的 0...

  • 最大子序和 LettCode(53)

    题目 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 示例...

  • 数据库学习线路图

    SQL 语法教程 SQL 教程SQL 简介SQL 语法SQL Select选择SQL SELECT DISTINC...

网友评论

      本文标题:lettcode sql

      本文链接:https://www.haomeiwen.com/subject/zkeidrtx.html