1、 第二高的薪水
select ifnull((select distinct Salary from Employee order by Salary desc limit 1,1),null) as SecondHighestSalary;
 
2、第N高的薪水
select distinct Salary from Employee e where N = (select count(distinct Salary) from Employee where Salary >= e.Salary );
 
3、分数排名
  select Score,(select count(distinct score) from Scores where score >= s.score) as Rank from Scores as s order by Score desc;
 
4、超过经理收入的员工
  select e1.Name as Employee from Employee as e1,Employee as e2 where e1.ManagerId=e2.Id and e1.Salary>e2.Salary;
 
5、 查找重复的电子邮箱
select Email from Person group by Email having count(Email)>1;
 
6、从不订购的客户
select c.Name as Customers from Customers as c left join Orders as o on c.Id = o.CustomerId where c.Id not in (select c.Id from Customers as c,Orders as o where c.Id = o.CustomerId);
 
7、部门工资最高的员工
    select d.Name as Department,e.Name as Employee,e.Salary from Department as d inner join Employee as e on d.Id = e.DepartmentId and e.Salary>=(select max(Salary) from Employee where DepartmentId=d.Id);
 
8、删除重复的电子邮箱
   delete p1.* from Person p1,Person p2 where p1.Email=p2.Email and p1.id>p2.id;
 
9、上升的温度
  select w1.Id from Weather w1 join Weather w2 on DATEDIFF(w1.RecordDate, w2.RecordDate) = 1 where w1.Temperature>w2.Temperature;
 
10、交换性别
update salary set
sex = case sex
when 'm' then 'f'
else 'm'
end;

leetcode数据库题目及答案汇总的更多相关文章

  1. Web前端面试题目及答案汇总

    HTML/CSS部分 1.什么是盒子模型? 在网页中,一个元素占有空间的大小由几个部分构成,其中包括元素的内容(content),元素的内边距(padding),元素的边框(border),元素的外边 ...

  2. LeetCode算法题目解答汇总(转自四火的唠叨)

    LeetCode算法题目解答汇总 本文转自<四火的唠叨> 只要不是特别忙或者特别不方便,最近一直保持着每天做几道算法题的规律,到后来随着难度的增加,每天做的题目越来越少.我的初衷就是练习, ...

  3. LeetCode高频题目(100)汇总-Java实现

    LeetCode高频题目(100)汇总-Java实现       LeetCode高频题目(100)汇总-Java实现 目录 第01-50题 [Leetcode-easy-1] Two Sum [Le ...

  4. 刷完了leetcode的数据库题目~

    很久很久很久之前,我上传了几条数据库题目,并没有坚持,今天跟新一下进度吧,其实没啥难度w(* ̄︶ ̄)

  5. Android面试题目及其答案

    转自:http://blog.csdn.net/wwj_748/article/details/8868640 Android面试题目及其答案 1.Android dvm的进程和Linux的进程, 应 ...

  6. LeetCode SQL题目(第一弹)

    LeetCode SQL题目 注意:Leetcode上的SQL编程题都提供了数据表的架构程序,只需要将它贴入本地数据库即可调试自己编写的程序 不管是MS-SQL Server还是MySQL都需要登陆才 ...

  7. 33条C#、.Net经典面试题目及答案

    33条C#..Net经典面试题目及答案[zt] 本文集中了多条常见的C#..Net经典面试题目例如".NET中类和结构的区别"."ASP.NET页面之间传递值的几种方式? ...

  8. 33条C#、.Net经典面试题目及答案[zt]

    33条C#..Net经典面试题目及答案[zt] 本文集中了多条常见的C#..Net经典面试题目例如“.NET中类和结构的区别”.“ASP.NET页面之间传递值的几种方式?”,并简明扼要的给出了答案,希 ...

  9. LeetCode All in One题解汇总(持续更新中...)

    突然很想刷刷题,LeetCode是一个不错的选择,忽略了输入输出,更好的突出了算法,省去了不少时间. dalao们发现了任何错误,或是代码无法通过,或是有更好的解法,或是有任何疑问和建议的话,可以在对 ...

随机推荐

  1. java虚拟机的学习书籍推荐

    javaEE开发已然是一个老生常谈的话题了,但经典之所以会成为经典,就是因为有可重复琢磨之处,每一次的反复推敲都会有不一样的收获.如果你不满足于做一个只会写if…else…的Java程序员,而是希望更 ...

  2. Hadoop MapReduce2.0(Yarn)

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/cqboy1991/article/details/25056283 MapReduce2.0(Yar ...

  3. Windows 数字化器类输入设备--笔设备分析(1)(原创)

    一.前言: 参考microsoft公司的链接:https://developer.microsoft.com/zh-cn/windows/hardware 将对Windows数字化器类输入设备--笔设 ...

  4. Ansible运维自动化

    Ansible运维自动化 一.Ansible-playbook的初步使用 playbook的使用,playbook可以把ansible的模块进行组合 ln -s /usr/local/python/b ...

  5. JAVA中的算法

    线性排序 冒泡排序 package com.jiedada.creat; public class maopao { public static void main(String[] args) { ...

  6. windows下配置apache+https

    通过https反向代理映射到http地址,可实现以https的方式,访问普通的http网站.主要涉及到以下三个配置文件的修改:httpd.confhttpd-ssl.confhttpd-vhosts. ...

  7. 使用iframe方式获得svg中的DOM元素,和svg 的 contentDocument 返回 null

    碰到这个的相关问题,百度找了好久,找到了个解决方法,原址 https://segmentfault.com/q/1010000009001758 var iframe = document.getEl ...

  8. global的使用

    对于一个全局变量,你的函数里如果只使用到了它的值,而没有对其赋值(指a = XXX这种写法)的话,就不需要声明global. 相反,如果你对其赋了值的话,那么你就需要声明global.声明global ...

  9. python 进程/线程/协程 测试

    # Author: yeshengbao # -- coding: utf-8 -- # @Time : 2018/5/24 21:38 # 进程:如一个人拥有分身(分数数最好为cpu核心数)几乎同时 ...

  10. 一、新建springBoot项目

    三种方式新建SpringBoot项目:  官网,  myeclipse,  idea 1.官方网站新建(https://start.spring.io/) 1)打开官网,选择自己需要的springBo ...