当前位置: 首页 > news >正文

leetcode-数据库题

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录

  • 175. 组合两个表
  • 176. 第二高的薪水
  • 177. 第N高的薪水
  • 178. 分数排名
  • 181. 超过经理收入的员工
  • 182. 查找重复的电子邮箱
  • 183. 从不订购的客户


175. 组合两个表

select p.FirstName, p.LastName, a.City, a.Statefrom Person p left join Address aon p.personid=a.personid

176. 第二高的薪水

select (select distinct salary from Employee order by salary desc  limit 1,1) as SecondHighestSalary

177. 第N高的薪水

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGINset N = N-1;RETURN (# Write your MySQL query statement below.select (select distinct salary from Employee order by salary desc  limit N,1) as SecondHighestSalary);
END

178. 分数排名

SELECT score, DENSE_RANK() OVER (ORDER BY score DESC) AS `rank`
FROM (SELECT score, ROW_NUMBER() OVER (ORDER BY score DESC) AS rnFROM Scores
) s
ORDER BY `rank` ASC;

181. 超过经理收入的员工

select a.name as Employee from Employee a join Employee b 
on a.managerId = b.id where a.salary > b.salary

182. 查找重复的电子邮箱

select distinct a.email  Email from  Person a left join Person b on a.email = b.email where a.id != b.id

183. 从不订购的客户

select a.Name Customers from ( select Name, Orders.Id from Customers left join Orders on Customers.Id = Orders.CustomerId ) a where a.Id is nullSELECT Name AS Customers
FROM Customers
WHERE Id NOT IN (SELECT CustomerId FROM Orders);
http://www.lryc.cn/news/62123.html

相关文章:

  • [元来学NVMe协议] NVMe IO 指令集(NVM 指令集)| Flush 命令
  • 信息的相关性和冗余度:信息在整个文明中的作用
  • python数据结构与算法-动态规划(最长公共子序列)
  • Java版企业电子招投标系统源码 Spring Cloud+Spring Boot 电子招标采购系统功能清单
  • 【c语言】函数的基本概念 | 函数堆栈调用原理
  • Vue.prototype 详解及使用
  • 音视频八股文(3)--ffmpeg常见命令(2)
  • 使用bert4keras出现的问题(Process finished with exit code -1073741819 (0xC0000005))
  • python协程实战
  • 【论文笔记】VideoGPT: Video Generation using VQ-VAE and Transformers
  • scala之基础面向对象
  • Qt5.12实战之多线程编程概念
  • 格式化数据恢复怎么做?超实用的3种方法在这!
  • 【Java|golang】1105. 填充书架---动态规划
  • linux基础命令
  • 【三十天精通Vue 3】 第十八天 Vue 3的国际化详解
  • 02 - 学会提问
  • Java经典的Main方法面试题
  • 世界大学电子电气工程TOP10,国内大学哪家强?
  • 5.3 牛顿-科茨公式
  • 全注解下的SpringIoc 续2-bean的生命周期
  • 【VQ-VAE代码实战】Neural Discrete Representation Learning
  • gpt3.5和gpt4区别-gpt3.5和gpt4
  • java获取当前系统时间
  • pbootcms自动配图出图插件
  • 手动测试台架搭建,让你的车载测试更轻松
  • 分组双轴图:揭示数据中的关联性和趋势变化
  • MATLAB函数封装1:生成QT可以调用的.dll动态链接库
  • 【算法题】2400. 恰好移动 k 步到达某一位置的方法数目
  • 探索【Stable-Diffusion WEBUI】的插件:骨骼姿态(OpenPose)