当前位置:Gxlcms > 数据库问题 > LeetCode sql

LeetCode sql

时间:2021-07-01 10:21:17 帮助过:4人阅读

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   

人气教程排行