From c9758d7e72052dde06b0bbf1a439ac987e7a5c0a Mon Sep 17 00:00:00 2001 From: zeekling Date: Sat, 21 Nov 2020 21:03:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9sql=E8=81=94=E7=B3=BB?= =?UTF-8?q?=E4=B8=BAsql=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hs_err_pid287213.log | 21 ------------------- sql/{从不订购的客户.md => 从不订购的客户.sql} | 7 +++---- ...重复的电子邮箱.md => 查找重复的电子邮箱.sql} | 7 +++---- ...经理收入的员工.md => 超过经理收入的员工.sql} | 8 +++---- 4 files changed, 9 insertions(+), 34 deletions(-) delete mode 100644 hs_err_pid287213.log rename sql/{从不订购的客户.md => 从不订购的客户.sql} (95%) rename sql/{查找重复的电子邮箱.md => 查找重复的电子邮箱.sql} (92%) rename sql/{超过经理收入的员工.md => 超过经理收入的员工.sql} (96%) diff --git a/hs_err_pid287213.log b/hs_err_pid287213.log deleted file mode 100644 index b740e52..0000000 --- a/hs_err_pid287213.log +++ /dev/null @@ -1,21 +0,0 @@ -# -# A fatal error has been detected by the Java Runtime Environment: -# -# SIGSEGV (0xb) at pc=0x00007f215cc73133, pid=287213, tid=287228 -# -# JRE version: OpenJDK Runtime Environment (11.0.9+11) (build 11.0.9+11-post-Debian-1) -# Java VM: OpenJDK 64-Bit Server VM (11.0.9+11-post-Debian-1, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64) -# Problematic frame: -# C [libjimage.so+0x3133] -# -# Core dump will be written. Default location: /home/zeek/project/leetCode/core -# -# If you would like to submit a bug report, please visit: -# https://bugs.debian.org/openjdk-11 -# - ---------------- S U M M A R Y ------------ - -Command Line: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:43579 -javaagent:/home/zeek/software/eclipse_java/configuration/org.eclipse.osgi/406/0/.cp/lib/javaagent-shaded.jar -Dfile.encoding=UTF-8 -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true com.leetcode.string.Convert2Zstr - -Host: \ No newline at end of file diff --git a/sql/从不订购的客户.md b/sql/从不订购的客户.sql similarity index 95% rename from sql/从不订购的客户.md rename to sql/从不订购的客户.sql index 3f6bcd0..171ec8d 100644 --- a/sql/从不订购的客户.md +++ b/sql/从不订购的客户.sql @@ -1,4 +1,4 @@ -## 题目 +/** 某网站包含两个表,Customers 表和 Orders 表。编写一个 SQL 查询,找出所有从不订购任何东西的客户。 Customers 表: @@ -31,10 +31,9 @@ Orders 表: | Max | +-----------+ ``` +**/ -## 答案 -```sql select Name as Customers from Customers a where a.id not in (select CustomerId from Orders) -``` + diff --git a/sql/查找重复的电子邮箱.md b/sql/查找重复的电子邮箱.sql similarity index 92% rename from sql/查找重复的电子邮箱.md rename to sql/查找重复的电子邮箱.sql index 7c7295c..4d29cc0 100644 --- a/sql/查找重复的电子邮箱.md +++ b/sql/查找重复的电子邮箱.sql @@ -1,4 +1,4 @@ -## 题目 +/** 编写一个 SQL 查询,查找 Person 表中所有重复的电子邮箱。 示例: ``` @@ -19,8 +19,7 @@ | a@b.com | +---------+ ``` +**/ -## 答案 -```sql select Email from Person group by Email having count(*) > 1 -``` + diff --git a/sql/超过经理收入的员工.md b/sql/超过经理收入的员工.sql similarity index 96% rename from sql/超过经理收入的员工.md rename to sql/超过经理收入的员工.sql index 21e8aba..1ac94ff 100644 --- a/sql/超过经理收入的员工.md +++ b/sql/超过经理收入的员工.sql @@ -1,4 +1,4 @@ -## 题目: +/** Employee 表包含所有员工,他们的经理也属于员工。每个员工都有一个 Id,此外还有一列对应员工的经理的 Id。 ``` @@ -22,11 +22,9 @@ Employee 表包含所有员工,他们的经理也属于员工。每个员工 | Joe | +----------+ ``` +**/ -## 答案 - -```sql select a.Name as Employee from Employee a, (select Salary,Id from Employee) b where a.ManagerId=b.Id and a.Salary > b.Salary -``` +