leetcode 176. Second Highest Salary
2016-08-08 14:35
316 查看
176. Second Highest Salary
Question
Editorial Solution
My Submissions
Total Accepted: 21825
Total Submissions: 95303
Difficulty: Easy
Write a SQL query to get the second highest salary from the
Employeetable.
+----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+
For example, given the above Employee table, the second highest salary is
200.
If there is no second highest salary, then the query should return
null.
Subscribe to see which companies asked this question
Have you met this question in a real interview?
# Write your MySQL query statement below select (select distinct (Salary) from Employee order by Salary Desc limit 1,1) as SecondHighestSalary
注意 order by 后面的Desc表示降序排列,asc表示升序排列
as
as不是给表里的字段取别名,而是给查询的结果字段取别名。其目的是让查询的结果展现更符合人们观看习惯,在多张表查询的时候可以直接的区别多张表的同名的字段。比如:
1、selec name as “姓名” ,sex as "性别" from user
2、select u.name as “姓名”,o.name as "英文名" ,u.sex as "性别" from user u ,other o where u.id = o.id;
相关文章推荐
- LeetCode-Algorithms #002 Add Two Numbers, Database #176 Second Highest Salary
- leetcode 176. Second Highest Salary
- 【leetcode Database】176. Second Highest Salary
- LeetCode Database #176 Second Highest Salary
- leetcode 176. Second Highest Salary
- Leetcode176. Second Highest Salary
- leetcode 176. Second Highest Salary
- leetcode 176. Second Highest Salary
- leetcode176---Second Highest Salary
- LeetCode 176. Second Highest Salary
- Leetcode 176 Second Highest Salary
- Leetcode 176. Second Highest Salary
- [理解leetcode解法]176. Second Highest Salary
- 【LeetCode】175、combine two tables ; 176. Second Highest Salary
- leetcode 176. Second Highest Salary
- Database LeetCode Second Highest Salary
- 176. Second Highest Salary
- LeetCode Second Highest Salary
- Second Highest Salary --leetCode
- leecode-database 176.Second Highest Salary