Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improved tasks 175-184#1982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
javadev merged 1 commit intojavadev:mainfromjscrdev:improve-175-184
May 22, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletionssrc/main/java/g0101_0200/s0175_combine_two_tables/script.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
# 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)
SELECT
FirstName,
LastName,
City,
State
FROM
Person
LEFT JOIN
Address
USING (PersonId);
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
# 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%)
SELECT ifnull(
(SELECT distinct(Salary)
FROM Employee
ORDER BY Salary DESC
LIMIT 1
OFFSET 1), NULL) SecondHighestSalary;
SELECT
IFNULL(
(
SELECT DISTINCT Salary
FROM Employee
ORDER BY Salary DESC
LIMIT 1 OFFSET 1
),
NULL
) AS SecondHighestSalary;
9 changes: 8 additions & 1 deletionsrc/main/java/g0101_0200/s0178_rank_scores/script.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
# Write your MySQL query statement below
# #Medium #Database #2022_06_26_Time_290_ms_(66.73%)_Space_0B_(100.00%)
select Score, DENSE_RANK() OVER(order by Score Desc) as "Rank" from Scores order by "Rank" Asc;
SELECT
Score,
DENSE_RANK() OVER (ORDER BY Score DESC) AS Rank
FROM
Scores
ORDER BY
Rank ASC;

View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
# Write your MySQL query statement below
# #Medium #Database #2024_07_15_Time_469_ms_(89.19%)_Space_0B_(100.00%)
SELECT DISTINCT l1.num AS ConsecutiveNums
FROM Logs l1
JOIN Logs l2 ON l1.id = l2.id - 1
JOIN Logs l3 ON l1.id = l3.id - 2
WHERE l1.num = l2.num AND l2.num = l3.num;
SELECT DISTINCT
l1.num AS ConsecutiveNums
FROM
Logs l1
JOIN Logs l2 ON l1.id = l2.id - 1
JOIN Logs l3 ON l1.id = l3.id - 2
WHERE
l1.num = l2.num
AND l2.num = l3.num;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
# Write your MySQL query statement below
# #Easy #Database #2022_06_27_Time_315_ms_(94.44%)_Space_0B_(100.00%)
select a.Name as Employee from Employee a left join Employee b on a.ManagerId=b.Id
where a.Salary > b.Salary and a.ManagerId is not null
SELECT
a.Name AS Employee
FROM
Employee a
LEFT JOIN Employee b ON a.ManagerId = b.Id
WHERE
a.Salary > b.Salary
AND a.ManagerId IS NOT NULL;
10 changes: 9 additions & 1 deletionsrc/main/java/g0101_0200/s0182_duplicate_emails/script.sql
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
# Write your MySQL query statement below
# #Easy #Database #SQL_I_Day_10_Where #2022_06_27_Time_303_ms_(92.08%)_Space_0B_(100.00%)
SELECT Email FROM Person GROUP BY Email HAVING COUNT(Email) > 1;
SELECT
Email
FROM
Person
GROUP BY
Email
HAVING
COUNT(Email) > 1;

View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
# Write your MySQL query statement below
# #Easy #Database #SQL_I_Day_1_Select #2022_06_27_Time_376_ms_(98.73%)_Space_0B_(100.00%)
SELECT c.Name as Customers
FROM Customers as c
LEFT JOIN Orders as o
ON c.Id = o.CustomerId
WHERE o.CustomerId is null
SELECT
c.Name AS Customers
FROM
Customers AS c
LEFT JOIN Orders AS o ON c.Id = o.CustomerId
WHERE
o.CustomerId IS NULL;
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,13 +5,18 @@ SELECT
Sel.Name AS Employee,
Sel.Salary AS Salary
FROM
(
SELECT
Name,
Salary,
DepartmentId,
DENSE_RANK() OVER (PARTITION BY DepartmentId ORDER BY Salary DESC) AS dr
FROM Employee
) AS Sel
INNER JOIN Department d ON d.Id = Sel.DepartmentId
WHERE Sel.dr = 1
(
SELECT
Name,
Salary,
DepartmentId,
DENSE_RANK() OVER (
PARTITION BY DepartmentId
ORDER BY Salary DESC
) AS dr
FROM
Employee
) AS Sel
INNER JOIN Department d ON d.Id = Sel.DepartmentId
WHERE
Sel.dr = 1;

[8]ページ先頭

©2009-2025 Movatter.jp