From c3696e308ff917b55bcdcbfb5c957ffc8973b3c9 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Mon, 30 Nov 2026 06:23:18 +0200 Subject: [PATCH 1/3] Improved task 175 --- .../s0175_combine_two_tables/readme.md | 18 +++++++----------- .../s0175_combine_two_tables/script.sql | 15 ++++----------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/main/java/g0101_0200/s0175_combine_two_tables/readme.md b/src/main/java/g0101_0200/s0175_combine_two_tables/readme.md index f335cc6f1..be56bdce2 100644 --- a/src/main/java/g0101_0200/s0175_combine_two_tables/readme.md +++ b/src/main/java/g0101_0200/s0175_combine_two_tables/readme.md @@ -2,8 +2,6 @@ Easy -SQL Schema - Table: `Person` +-------------+---------+ @@ -13,8 +11,7 @@ Table: `Person` | lastName | varchar | | firstName | varchar | +-------------+---------+ - - personId is the primary key column for this table. + personId is the primary key (column with unique values) for this table. This table contains information about the ID of some persons and their first and last names. Table: `Address` @@ -27,19 +24,18 @@ Table: `Address` | city | varchar | | state | varchar | +-------------+---------+ - - addressId is the primary key column for this table. + addressId is the primary key (column with unique values) for this table. Each row of this table contains information about the city and state of one person with ID = PersonId. -Write an SQL query to report the first name, last name, city, and state of each person in the `Person` table. If the address of a `personId` is not present in the `Address` table, report `null` instead. +Write a solution to report the first name, last name, city, and state of each person in the `Person` table. If the address of a `personId` is not present in the `Address` table, report `null` instead. Return the result table in **any order**. -The query result format is in the following example. +The result format is in the following example. **Example 1:** -**Input:** +**Input:** Person table: +----------+----------+-----------+ @@ -48,7 +44,7 @@ The query result format is in the following example. | 1 | Wang | Allen | | 2 | Alice | Bob | +----------+----------+-----------+ - + Address table: +-----------+----------+---------------+------------+ | addressId | personId | city | state | @@ -68,4 +64,4 @@ The query result format is in the following example. **Explanation:** -There is no address in the address table for the personId = 1 so we return null in their city and state. addressId = 1 contains information about the address of personId = 2. +There is no address in the address table for the personId = 1 so we return null in their city and state. addressId = 1 contains information about the address of personId = 2. \ No newline at end of file diff --git a/src/main/java/g0101_0200/s0175_combine_two_tables/script.sql b/src/main/java/g0101_0200/s0175_combine_two_tables/script.sql index ab0dd6a27..3486326c8 100644 --- a/src/main/java/g0101_0200/s0175_combine_two_tables/script.sql +++ b/src/main/java/g0101_0200/s0175_combine_two_tables/script.sql @@ -1,12 +1,5 @@ # Write your MySQL query statement below -# #Easy #Database #SQL_I_Day_5_Union #2022_06_26_Time_491_ms_(32.30%)_Space_0B_(100.00%) -SELECT - FirstName, - LastName, - City, - State -FROM - Person -LEFT JOIN - Address -USING (PersonId); +# #Easy #Database #SQL_I_Day_5_Union #2026_11_30_Time_364_ms_(89.70%)_Space_0.0_MB_(100.00%) +SELECT p.firstName , p.lastName , a.city , a.state +FROM Person p left join Address a +on p.personId = a.personId; From 44f41a9dbbc6bc5810040dc48bc6ffc0aa2857fb Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Mon, 30 Nov 2026 06:32:15 +0200 Subject: [PATCH 2/3] Improved task --- .../java/g0101_0200/s0176_second_highest_salary/script.sql | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/g0101_0200/s0176_second_highest_salary/script.sql b/src/main/java/g0101_0200/s0176_second_highest_salary/script.sql index a6758a294..3556bfd5c 100644 --- a/src/main/java/g0101_0200/s0176_second_highest_salary/script.sql +++ b/src/main/java/g0101_0200/s0176_second_highest_salary/script.sql @@ -1,6 +1,5 @@ # Write your MySQL query statement below -# #Medium #Database #SQL_I_Day_4_Union_and_Select -# #2022_07_10_Time_225_ms_(73.10%)_Space_0B_(100.00%) +# #Easy #Database #SQL_I_Day_5_Union #2026_11_30_Time_336_ms_(96.67%)_Space_0B_(100.00%) SELECT IFNULL( ( From 4ee21ec7c8ff06a8473a12dde4047f9e7dd8dfd3 Mon Sep 17 00:00:00 2001 From: Valentyn Kolesnikov Date: Mon, 30 Nov 2026 06:33:45 +0200 Subject: [PATCH 3/3] Improved task --- src/main/java/g0101_0200/s0175_combine_two_tables/script.sql | 2 +- .../java/g0101_0200/s0176_second_highest_salary/script.sql | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/g0101_0200/s0175_combine_two_tables/script.sql b/src/main/java/g0101_0200/s0175_combine_two_tables/script.sql index 3486326c8..51c2ec9d9 100644 --- a/src/main/java/g0101_0200/s0175_combine_two_tables/script.sql +++ b/src/main/java/g0101_0200/s0175_combine_two_tables/script.sql @@ -1,5 +1,5 @@ # Write your MySQL query statement below -# #Easy #Database #SQL_I_Day_5_Union #2026_11_30_Time_364_ms_(89.70%)_Space_0.0_MB_(100.00%) +# #Easy #Database #SQL_I_Day_5_Union #2026_11_30_Time_336_ms_(96.67%)_Space_0B_(100.00%) SELECT p.firstName , p.lastName , a.city , a.state FROM Person p left join Address a on p.personId = a.personId; diff --git a/src/main/java/g0101_0200/s0176_second_highest_salary/script.sql b/src/main/java/g0101_0200/s0176_second_highest_salary/script.sql index 3556bfd5c..a6758a294 100644 --- a/src/main/java/g0101_0200/s0176_second_highest_salary/script.sql +++ b/src/main/java/g0101_0200/s0176_second_highest_salary/script.sql @@ -1,5 +1,6 @@ # Write your MySQL query statement below -# #Easy #Database #SQL_I_Day_5_Union #2026_11_30_Time_336_ms_(96.67%)_Space_0B_(100.00%) +# #Medium #Database #SQL_I_Day_4_Union_and_Select +# #2022_07_10_Time_225_ms_(73.10%)_Space_0B_(100.00%) SELECT IFNULL( (