提交 3e0874b6 编写于 作者: 每日一练社区's avatar 每日一练社区

add exercises

上级 56f463fa
select p.FirstName,
p.LastName,
a.City,
a.State
from Person p
left join Address a on a.PersonId = p.PersonId
\ No newline at end of file
select Max(Salary) SecondHighestSalary
from Employee
where (
select Max(Salary)
from Employee
) > Salary
\ No newline at end of file
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT BEGIN
SET N := N -1;
RETURN (
# Write your MySQL query statement below.
SELECT salary
FROM employee
GROUP BY salary
ORDER BY salary DESC
LIMIT N, 1
);
\ No newline at end of file
select Score,
(
select count(distinct Score)
from Scores as s2
where s2.Score >= s1.Score
) Rank
from Scores as s1
order by Score DESC;
\ No newline at end of file
# Write your MySQL query statement below
select distinct Num as ConsecutiveNums
from (
select Num,
if(@pre = Num, @count := @count + 1, @count := 1) as nums,
@pre := Num
from Logs as l,
(
select @pre := null,
@count := 1
) as pc
) as n
where nums >= 3;
\ No newline at end of file
select name Employee
from Employee e1
where e1.Salary > (
select e2.Salary fromEmployee e2
where e1.ManagerId = e2.Id
)
\ No newline at end of file
select Email
from Person
group by Email
having count(Email) > 1;
\ No newline at end of file
select c.name Customers
from Customers c
left join Orders o on o.CustomerId = c.Id
where o.CustomerId is null
\ No newline at end of file
SELECT d.NAME AS 'Department',
e.NAME AS 'Employee',
e.Salary
FROM employee e
JOIN department d ON e.departmentId = d.Id
WHERE (e.departmentId, e.Salary) IN (
SELECT departmentId,
Max(Salary)
FROM employee
GROUP BY departmentId
);
\ No newline at end of file
SELECT Department.Name AS Department,
e1.Name AS Employee,
e1.Salary AS Salary
FROM Employee e1
JOIN Department ON e1.DepartmentId = Department.Id
WHERE 3 > (
SELECT COUNT(DISTINCT e2.Salary)
FROM Employee e2
WHERE e2.Salary > e1.Salary
AND e1.DepartmentId = e2.DepartmentId
)
ORDER BY Department.Name,
e1.Salary DESC
\ No newline at end of file
......@@ -27,8 +27,17 @@ def leetcode_helper():
shutil.copy(cpp_code_src_path, cpp_code_dst_path)
else:
cpp_code_dst_path = os.path.join(dir, 'solution.cpp')
shell_code_dst_path = os.path.join(dir, 'solution.sh')
sql_code_dst_path = os.path.join(dir, 'solution.sql')
if not os.path.exists(cpp_code_dst_path):
open(cpp_code_dst_path, 'w', encoding='utf-8')
if 100 <= int(exercises_id) and int(exercises_id) < 203:
with open(cpp_code_dst_path, 'r', encoding='utf-8') as f:
cpp_code = f.read()
if cpp_code == '' and not os.path.exists(shell_code_dst_path) and not os.path.exists(sql_code_dst_path):
print(cpp_code_dst_path)
desc_src_path = os.path.join(crawer_leetcode_dir, str(int(exercises_id) + 1) + '.html')
desc_dst_path = os.path.join(dir, 'desc.html')
# print(desc_src_path)
......@@ -36,9 +45,11 @@ def leetcode_helper():
if os.path.exists(desc_src_path):
shutil.copy(desc_src_path, desc_dst_path)
else:
print("该路径不存在,请检查: {}".format(desc_src_path))
else:
pass
# print("该路径不存在,请检查: {}".format(desc_src_path))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册