【Leetcode】176. Second Highest Salary (Easy)
1.題目
Write a SQL query to get the second highest salary from the Employee
table.
+----+--------+ | Id | Salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+
For example, given the above Employee table, the query should return 200
as the second highest salary. If there is no second highest salary, then the query should return null
+---------------------+ | SecondHighestSalary | +---------------------+ | 200 | +---------------------+翻譯:找到一張表中,第二大的值標記為SecondHighestSalary,如果沒有則返回null。
2.思路
小於最大Salary的最大Salary即為第二大的Salary值
3.演算法
select MAX(Salary) as SecondHighestSalary from Employee where Salary<(select MAX(Salary) from Employee)
相關推薦
【Leetcode】176. Second Highest Salary (Easy)
1.題目Write a SQL query to get the second highest salary from the Employee table.+----+--------+ | Id | Salary | +----+--------+ | 1 | 100
【Leetcode】482. License Key Formatting(Easy)
1.題目You are given a license key represented as a string S which consists only alphanumeric character and dashes. The string is separated i
【Leetcode】196. Delete Duplicate Emails (Easy)
1.題目Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique emails based on its smallest Id.翻
176. Second Highest Salary(Leetcode)
文章出處:http://www.cnblogs.com/grandyang/p/5348961.html Write a SQL query to get the second highest salary from the Employee table. +----+
【LeetCode】184. Department Highest Salary
The Employee table holds all employees. Every employee has an Id, a salary, and there is also a column for the department Id. +----+----
[理解leetcode解法]176. Second Highest Salary
176. Second Highest Salary #題目: Write a SQL query to get the second highest salary from theEmploy
【LeetCode】40. Combination Sum II(C++)
地址:https://leetcode.com/problems/combination-sum-ii/ 題目: Given a collection of candidate numbers (candidates) and a target number (target), fi
【LeetCode】29. Divide Two Integers(C++)
地址:https://leetcode.com/problems/divide-two-integers/ 題目: Given two integers dividend and divisor, divide two integers without using multiplic
【LeetCode】73. Set Matrix Zeroes(C++)
地址:https://leetcode.com/problems/set-matrix-zeroes/ 題目: Given a m m
【LeetCode】64. Minimum Path Sum(C++)
地址:https://leetcode.com/problems/minimum-path-sum/ 題目: Given a m ∗
【LeetCode】63. Unique Paths II(C++)
地址:https://leetcode.com/problems/unique-paths-ii/ 題目: A robot is located at the top-left corner of a m
【LeetCode】93. Restore IP Addresses(C++)
地址:https://leetcode.com/problems/restore-ip-addresses/ 題目: Given a string containing only digits, restore it by returning all possible valid I
【LeetCode】743. Network Delay Time(C++)
題目: There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges times[i] = (u, v, w), where
【LeetCode】754. Reach a Number(C++)
題目: You are standing at position 0 on an infinite number line. There is a goal at position target. On each move, you can either go
【LeetCode】10. Regular Expression Matching(C++)
地址:https://leetcode.com/problems/regular-expression-matching/ 題目: Given an input string (s) and a pattern (p), implement regular expression ma
【LeetCode】5. Longest Palindromic Substring(C++)
題目: Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1:
【LeetCode】32. Longest Valid Parentheses(C++)
地址:https://leetcode.com/problems/longest-valid-parentheses/ 題目: Given a string containing just the characters '(' and ')', find the length of
【LeetCode】76. Minimum Window Substring(C++)
地址:https://leetcode.com/problems/minimum-window-substring/ 題目: Given a string S and a string T, find the minimum window in S which will contai
【LeetCode】45. Jump Game II(C++)
地址:https://leetcode.com/problems/jump-game-ii/ 題目: Given an array of non-negative integers, you are initially positioned at the first index of
【LeetCode】696. Count Binary Substrings(C++)
地址:https://leetcode.com/problems/count-binary-substrings/ 題目: Give a string s, count the number of non-empty (contiguous) substrings that have