码迷,mamicode.com
首页 > 数据库 > 详细

LeetCode sql

时间:2020-07-03 15:28:30      阅读:47      评论:0      收藏:0      [点我收藏+]

标签:turn   func   order   select   http   简单   strong   Nid   cond   

1.【简单】组合两个表

select p.FirstName,p.LastName,a.City,a.State from person p left join address a on p.personid=a.personid;

2.【简单】第二高的薪水

select ifnull((select distinct(Salary) from Employee order by Salary desc limit 1,1),null) as SecondHighestSalary;

3.【中等】第N高的薪水

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
set n=n-1;
  RETURN (
      # Write your MySQL query statement below.
      select distinct Salary as getNthHighestSalary
      from Employee
      order by Salary DESC
      limit N,1
  );
END

4.【简单】有趣的电影

LeetCode sql

标签:turn   func   order   select   http   简单   strong   Nid   cond   

原文地址:https://www.cnblogs.com/hankleo/p/13230321.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!