From 98e26cf1ae001f6ca29c0d45fa867b87c7134086 Mon Sep 17 00:00:00 2001 From: liujiayu03 <15822882820@163.com> Date: Thu, 6 Aug 2020 16:22:49 +0800 Subject: [PATCH] leetcode 180~183 --- solution/0100-0199/0180.Consecutive Numbers/README.md | 6 ++++-- solution/0100-0199/0180.Consecutive Numbers/README_EN.md | 6 ++++-- solution/0100-0199/0180.Consecutive Numbers/Solution.sql | 3 +++ .../README.md | 5 +++-- .../README_EN.md | 5 +++-- .../Solution.sql | 2 ++ solution/0100-0199/0182.Duplicate Emails/README.md | 4 ++-- solution/0100-0199/0182.Duplicate Emails/README_EN.md | 4 ++-- solution/0100-0199/0182.Duplicate Emails/Solution.sql | 2 ++ solution/0100-0199/0183.Customers Who Never Order/README.md | 5 +++-- .../0100-0199/0183.Customers Who Never Order/README_EN.md | 5 +++-- .../0100-0199/0183.Customers Who Never Order/Solution.sql | 2 ++ 12 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 solution/0100-0199/0180.Consecutive Numbers/Solution.sql create mode 100644 solution/0100-0199/0181.Employees Earning More Than Their Managers/Solution.sql create mode 100644 solution/0100-0199/0182.Duplicate Emails/Solution.sql create mode 100644 solution/0100-0199/0183.Customers Who Never Order/Solution.sql diff --git a/solution/0100-0199/0180.Consecutive Numbers/README.md b/solution/0100-0199/0180.Consecutive Numbers/README.md index 2981460140e06..b57eed19b7d96 100644 --- a/solution/0100-0199/0180.Consecutive Numbers/README.md +++ b/solution/0100-0199/0180.Consecutive Numbers/README.md @@ -39,7 +39,9 @@ ### **SQL** ``` - +select distinct(Num) as ConsecutiveNums from Logs Curr where + Num = (select Num from Logs where id = Curr.id - 1) and + Num = (select Num from Logs where id = Curr.id - 2) ``` - \ No newline at end of file + diff --git a/solution/0100-0199/0180.Consecutive Numbers/README_EN.md b/solution/0100-0199/0180.Consecutive Numbers/README_EN.md index b1278ff4e8271..caab964f60935 100644 --- a/solution/0100-0199/0180.Consecutive Numbers/README_EN.md +++ b/solution/0100-0199/0180.Consecutive Numbers/README_EN.md @@ -64,7 +64,9 @@ ### **SQL** ``` - +select distinct(Num) as ConsecutiveNums from Logs Curr where + Num = (select Num from Logs where id = Curr.id - 1) and + Num = (select Num from Logs where id = Curr.id - 2) ``` - \ No newline at end of file + diff --git a/solution/0100-0199/0180.Consecutive Numbers/Solution.sql b/solution/0100-0199/0180.Consecutive Numbers/Solution.sql new file mode 100644 index 0000000000000..133095e6acc38 --- /dev/null +++ b/solution/0100-0199/0180.Consecutive Numbers/Solution.sql @@ -0,0 +1,3 @@ +select distinct(Num) as ConsecutiveNums from Logs Curr where + Num = (select Num from Logs where id = Curr.id - 1) and + Num = (select Num from Logs where id = Curr.id - 2) diff --git a/solution/0100-0199/0181.Employees Earning More Than Their Managers/README.md b/solution/0100-0199/0181.Employees Earning More Than Their Managers/README.md index ab01245aed071..58d4b5f874c71 100644 --- a/solution/0100-0199/0181.Employees Earning More Than Their Managers/README.md +++ b/solution/0100-0199/0181.Employees Earning More Than Their Managers/README.md @@ -36,7 +36,8 @@ ### **SQL** ``` - +select Name as Employee from Employee Curr where + Salary > (select Salary from Employee where Id = Curr.ManagerId) ``` - \ No newline at end of file + diff --git a/solution/0100-0199/0181.Employees Earning More Than Their Managers/README_EN.md b/solution/0100-0199/0181.Employees Earning More Than Their Managers/README_EN.md index 3736d95a8506e..ae39ba1bd5199 100644 --- a/solution/0100-0199/0181.Employees Earning More Than Their Managers/README_EN.md +++ b/solution/0100-0199/0181.Employees Earning More Than Their Managers/README_EN.md @@ -58,7 +58,8 @@ ### **SQL** ``` - +select Name as Employee from Employee Curr where + Salary > (select Salary from Employee where Id = Curr.ManagerId) ``` - \ No newline at end of file + diff --git a/solution/0100-0199/0181.Employees Earning More Than Their Managers/Solution.sql b/solution/0100-0199/0181.Employees Earning More Than Their Managers/Solution.sql new file mode 100644 index 0000000000000..53ea54c825e4b --- /dev/null +++ b/solution/0100-0199/0181.Employees Earning More Than Their Managers/Solution.sql @@ -0,0 +1,2 @@ +select Name as Employee from Employee Curr where + Salary > (select Salary from Employee where Id = Curr.ManagerId) diff --git a/solution/0100-0199/0182.Duplicate Emails/README.md b/solution/0100-0199/0182.Duplicate Emails/README.md index ad1615eaa7a68..f452d149fd4c7 100644 --- a/solution/0100-0199/0182.Duplicate Emails/README.md +++ b/solution/0100-0199/0182.Duplicate Emails/README.md @@ -39,7 +39,7 @@ ### **SQL** ``` - +select Email from Person group by Email having count(Email) > 1 ``` - \ No newline at end of file + diff --git a/solution/0100-0199/0182.Duplicate Emails/README_EN.md b/solution/0100-0199/0182.Duplicate Emails/README_EN.md index dfcfd45404e8d..7b1a2409cc1c9 100644 --- a/solution/0100-0199/0182.Duplicate Emails/README_EN.md +++ b/solution/0100-0199/0182.Duplicate Emails/README_EN.md @@ -60,7 +60,7 @@ ### **SQL** ``` - +select Email from Person group by Email having count(Email) > 1 ``` - \ No newline at end of file + diff --git a/solution/0100-0199/0182.Duplicate Emails/Solution.sql b/solution/0100-0199/0182.Duplicate Emails/Solution.sql new file mode 100644 index 0000000000000..53ea54c825e4b --- /dev/null +++ b/solution/0100-0199/0182.Duplicate Emails/Solution.sql @@ -0,0 +1,2 @@ +select Name as Employee from Employee Curr where + Salary > (select Salary from Employee where Id = Curr.ManagerId) diff --git a/solution/0100-0199/0183.Customers Who Never Order/README.md b/solution/0100-0199/0183.Customers Who Never Order/README.md index 96d24ad780cfe..bdf5b7eb920ab 100644 --- a/solution/0100-0199/0183.Customers Who Never Order/README.md +++ b/solution/0100-0199/0183.Customers Who Never Order/README.md @@ -49,7 +49,8 @@ ### **SQL** ``` - +select Name as Customers from Customers + where id not in (select CustomerId from Orders) ``` - \ No newline at end of file + diff --git a/solution/0100-0199/0183.Customers Who Never Order/README_EN.md b/solution/0100-0199/0183.Customers Who Never Order/README_EN.md index 86aa0a49abc1b..1eb79798aae0e 100644 --- a/solution/0100-0199/0183.Customers Who Never Order/README_EN.md +++ b/solution/0100-0199/0183.Customers Who Never Order/README_EN.md @@ -86,7 +86,8 @@ ### **SQL** ``` - +select Name as Customers from Customers + where id not in (select CustomerId from Orders) ``` - \ No newline at end of file + diff --git a/solution/0100-0199/0183.Customers Who Never Order/Solution.sql b/solution/0100-0199/0183.Customers Who Never Order/Solution.sql new file mode 100644 index 0000000000000..fcf5ca3bd7d22 --- /dev/null +++ b/solution/0100-0199/0183.Customers Who Never Order/Solution.sql @@ -0,0 +1,2 @@ +select Name as Customers from Customers + where id not in (select CustomerId from Orders)