Skip to content

Commit 706e57c

Browse files
committed
Merge branch 'master' of github.com:swiftwind0405/leetcode into master
2 parents 1b18b54 + 65b7839 commit 706e57c

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
|628|[Maximum Product of Three Numbers](https://leetcode.com/problems/maximum-product-of-three-numbers/) | |Easy|
7474
|627|[Swap Salary](https://leetcode.com/problems/swap-salary/) | [Mysql](./algorithm/swapSalary/Solution.java) | |Easy|
7575
|623|[Add One Row to Tree](https://leetcode.com/problems/add-one-row-to-tree/) | |Medium|
76+
|595|[Big Countries](https://leetcode.com/problems/big-countries/)| [Mysql](./algorithms/bigCountries/Solution.sql) |Easy|
7677
|581|[Shortest Unsorted Continuous Subarray](https://leetcode.com/problems/shortest-unsorted-continuous-subarray/) | |Easy|
7778
|572|[Subtree of Another Tree](https://leetcode.com/problems/subtree-of-another-tree/) | |Easy|
7879
|563|[Binary Tree Tilt](https://leetcode.com/problems/binary-tree-tilt/) | [java](./algorithms/binaryTreeTilt/Solution.java) |Easy|
@@ -241,7 +242,9 @@
241242
|186|[Reverse Words in a String II](https://leetcode.com/problems/reverse-words-in-a-string-ii/) ♥ | |Medium|
242243
|183|[Customers Who Never Order](https://leetcode.com/problems/customers-who-never-order/)| [Mysql](./algorithms/customersWhoNeverOrder/Solution.sql) |Easy|
243244
|182|[Duplicate Email](https://leetcode.com/problems/duplicate-emails/)| [Mysql](./algorithms/duplicateEmails/Solution.sql) |Easy|
245+
|181|[Employees Earning More Than Their Managers](https://leetcode.com/problems/employees-earning-more-than-their-managers/)| [Mysql](./algorithms/employeesEarningMoreThanTheirManagers/Solution.sql) |Easy|
244246
|179|[Largest Number](https://leetcode.com/problems/largest-number/) | |Medium|
247+
|176|[Second Highest Salary](https://leetcode.com/problems/second-highest-salary/)| [Mysql](./algorithms/secondHightestSalary/Solution.sql) |Easy|
245248
|175|[Combine Two Tables](https://leetcode.com/problems/combine-two-tables/)| [Mysql](./algorithms/combineTwoTable/Solution.sql) |Easy|
246249
|174|[Dungeon Game](https://leetcode.com/problems/dungeon-game/) | |Hard|
247250
|173|[Binary Search Tree Iterator](https://leetcode.com/problems/binary-search-tree-iterator/) | |Medium|

algorithms/bigCountries/Solution.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-- UNION 连接自查询 或者 使用 Where Or
2+
-- 因为 where or 比较熟悉 采用 UNION 进行题解
3+
4+
SELECT
5+
name, population, area
6+
FROM
7+
world
8+
WHERE
9+
area > 3000000
10+
11+
UNION
12+
13+
SELECT
14+
name, population, area
15+
FROM
16+
world
17+
WHERE
18+
population > 25000000
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- 第一种连接两个表的方式
2+
SELECT
3+
a.Name AS 'Employee'
4+
FROM
5+
Employee AS a,
6+
Employee AS b
7+
WHERE
8+
a.ManagerId = b.Id
9+
AND a.Salary > b.Salary
10+
;
11+
12+
-- 使用 JOIN 单独进行两张表连接
13+
SELECT
14+
a.Name AS 'Employee'
15+
FROM
16+
Employee AS a,
17+
Employee AS b
18+
WHERE
19+
a.ManagerId = b.Id
20+
AND a.Salary > b.Salary
21+
;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- 使用 DISTINCT 进行去重
2+
SELECT
3+
(SELECT DISTINCT
4+
Salary
5+
FROM
6+
Employee
7+
ORDER BY Salary DESC
8+
LIMIT 1 OFFSET 1) AS SecondHighestSalary

0 commit comments

Comments
 (0)