You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/kotlin/g0101_0200/s0175_combine_two_tables/readme.md
+49-5Lines changed: 49 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,30 @@ SQL Schema
6
6
7
7
Table: `Person`
8
8
9
-
+-------------+---------+ | Column Name | Type | +-------------+---------+ | personId | int | | lastName | varchar | | firstName | varchar | +-------------+---------+ personId is the primary key column for this table. This table contains information about the ID of some persons and their first and last names.
9
+
+-------------+---------+
10
+
| Column Name | Type |
11
+
+-------------+---------+
12
+
| personId | int |
13
+
| lastName | varchar |
14
+
| firstName | varchar |
15
+
+-------------+---------+
16
+
17
+
personId is the primary key column for this table.
18
+
This table contains information about the ID of some persons and their first and last names.
10
19
11
20
Table: `Address`
12
21
13
-
+-------------+---------+ | Column Name | Type | +-------------+---------+ | addressId | int | | personId | int | | city | varchar | | state | varchar | +-------------+---------+ addressId is the primary key column for this table. Each row of this table contains information about the city and state of one person with ID = PersonId.
22
+
+-------------+---------+
23
+
| Column Name | Type |
24
+
+-------------+---------+
25
+
| addressId | int |
26
+
| personId | int |
27
+
| city | varchar |
28
+
| state | varchar |
29
+
+-------------+---------+
30
+
31
+
addressId is the primary key column for this table.
32
+
Each row of this table contains information about the city and state of one person with ID = PersonId.
14
33
15
34
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.
16
35
@@ -20,8 +39,33 @@ The query result format is in the following example.
20
39
21
40
**Example 1:**
22
41
23
-
**Input:**Person table: +----------+----------+-----------+ | personId | lastName | firstName | +----------+----------+-----------+ | 1 | Wang | Allen | | 2 | Alice | Bob | +----------+----------+-----------+ Address table: +-----------+----------+---------------+------------+ | addressId | personId | city | state | +-----------+----------+---------------+------------+ | 1 | 2 | New York City | New York | | 2 | 3 | Leetcode | California | +-----------+----------+---------------+------------+
42
+
**Input:**
24
43
25
-
**Output:** +-----------+----------+---------------+----------+ | firstName | lastName | city | state | +-----------+----------+---------------+----------+ | Allen | Wang | Null | Null | | Bob | Alice | New York City | New York | +-----------+----------+---------------+----------+
**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.
Copy file name to clipboardExpand all lines: src/main/kotlin/g0101_0200/s0176_second_highest_salary/readme.md
+40-5Lines changed: 40 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,55 @@ SQL Schema
6
6
7
7
Table: `Employee`
8
8
9
-
+-------------+------+ | Column Name | Type | +-------------+------+ | id | int | | salary | int | +-------------+------+ id is the primary key column for this table. Each row of this table contains information about the salary of an employee.
9
+
+-------------+------+
10
+
| Column Name | Type |
11
+
+-------------+------+
12
+
| id | int |
13
+
| salary | int |
14
+
+-------------+------+
15
+
id is the primary key column for this table.
16
+
Each row of this table contains information about the salary of an employee.
10
17
11
18
Write an SQL query to report the second highest salary from the `Employee` table. If there is no second highest salary, the query should report `null`.
12
19
13
20
The query result format is in the following example.
Copy file name to clipboardExpand all lines: src/main/kotlin/g0101_0200/s0177_nth_highest_salary/readme.md
+42-6Lines changed: 42 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,20 +6,56 @@ SQL Schema
6
6
7
7
Table: `Employee`
8
8
9
-
+-------------+------+ | Column Name | Type | +-------------+------+ | id | int | | salary | int | +-------------+------+ id is the primary key column for this table. Each row of this table contains information about the salary of an employee.
9
+
+-------------+------+
10
+
| Column Name | Type |
11
+
+-------------+------+
12
+
| id | int |
13
+
| salary | int |
14
+
+-------------+------+
15
+
id is the primary key column for this table. Each row of this table contains information about the salary of an employee.
10
16
11
-
Write an SQL query to report the <code>n<sup>th</sup></code> highest salary from the `Employee` table. If there is no <code>n<sup>th</sup></code> highest salary, the query should report `null`.
17
+
Write an SQL query to report the `nth` highest salary from the `Employee` table. If there is no `nth` highest salary, the query should report `null`.
12
18
13
19
The query result format is in the following example.
Copy file name to clipboardExpand all lines: src/main/kotlin/g0101_0200/s0178_rank_scores/readme.md
+34-4Lines changed: 34 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,14 @@ SQL Schema
6
6
7
7
Table: `Scores`
8
8
9
-
+-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | score | decimal | +-------------+---------+ id is the primary key for this table. Each row of this table contains the score of a game. Score is a floating point value with two decimal places.
9
+
+-------------+---------+
10
+
| Column Name | Type |
11
+
+-------------+---------+
12
+
| id | int |
13
+
| score | decimal |
14
+
+-------------+---------+
15
+
id is the primary key for this table.
16
+
Each row of this table contains the score of a game. Score is a floating point value with two decimal places.
10
17
11
18
Write an SQL query to rank the scores. The ranking should be calculated according to the following rules:
12
19
@@ -20,6 +27,29 @@ The query result format is in the following example.
0 commit comments