LeetCode 数据库 627、620、626、601、596、595、197、176、175

LeetCode 627

在这里插入图片描述
解题思路:

  • if (sex = ‘m’,‘f’,‘m’);
  • char(ascii(‘m’) + ascii(‘f’) - ascii(sex));

LeetCode 620

在这里插入图片描述
解题思路:

  • select * from cinema where id%2 = 1 and description != ‘boring’ order by rating desc

LeetCode 626

在这里插入图片描述
解题思路:

  • select
    (
    case
    when id % 2 = 1 and id = (select count(1) from seat) then id
    when id % 2 = 1 then id + 1
    else id - 1
    end
    ) as id, student
    from seat
    order by id

LeetCode 601

在这里插入图片描述
解题思路:

  • select distinct a.* from
    stadium as a, stadium as b, stadium as c
    where a.people >= 100 and b.people >= 100 and c.people >= 100
    and (
    (a.id = b.id - 1 and b.id = c.id - 1) or
    (a.id = b.id - 1 and a.id = c.id + 1) or
    (a.id = b.id + 1 and b.id = c.id + 1)
    )
    order by a.id

LeetCode 596

在这里插入图片描述
解题思路:

  • select class from courses
    group by class
    having count(distinct student) >= 5

LeetCode 595

在这里插入图片描述
解题思路:

  • select name, population, area from World
    where area > 3000000 or population > 25000000

LeetCode 197

在这里插入图片描述
解题思路:

  • select a.id as id from weather a,weather b
    where datediff(a.RecordDate,b.RecordDate)=1
    and a.temperature>b.temperature

LeetCode 176

在这里插入图片描述

  • select (
    select DISTINCT Salary from Employee
    order by Salary desc
    limit 1,1) as SecondHighestSalary

LeetCode 175

在这里插入图片描述
解题思路:

  • select p.FirstName, p.LastName, a.City, a.State
    from Person as p left join Address as a
    on p.PersonId = a.PersonId

LeetCode 180

在这里插入图片描述
解题思路:

  • select DISTINCT l1.Num as ‘ConsecutiveNums’ from Logs as l1, Logs as l2, Logs as l3
    where l1.id = l2.id - 1 and l2.id = l3.id - 1 and l1.Num = l2.Num and l2.Num = l3.Num
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Happy王子乐

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值