From 0098b5e6eb0e5e8b39295746e6615d9959b6ef67 Mon Sep 17 00:00:00 2001 From: ivanbyone Date: Sat, 28 Jun 2025 14:14:19 +0300 Subject: [PATCH 1/2] task: #181 --- .sqlfluff | 2 +- README.md | 5 +-- ...oyees Earning More Than Their Managers.sql | 31 +++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 leetcode/easy/181. Employees Earning More Than Their Managers.sql diff --git a/.sqlfluff b/.sqlfluff index 752ca1c..c7b0e0c 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -4,4 +4,4 @@ exclude_rules = LT01, CP02 [sqlfluff:rules] keywords_capitalisation_policy = upper -max_line_length = 100 +max_line_length = 120 diff --git a/README.md b/README.md index 4fa7d9a..a8397b1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Leetcode (PostgreSQL) [![MIT licensed](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENSE) -[![CI](https://github.com/ivanbyone/hookify/actions/workflows/ci.yml/badge.svg)](https://github.com/Ivanbyone/leetcode-sql//actions) +[![CI](https://github.com/ivanbyone/leetcode-sql/actions/workflows/ci.yml/badge.svg)](https://github.com/Ivanbyone/leetcode-sql//actions) ## Description @@ -33,8 +33,9 @@ Have a good contributing! ## Task List 1. [Easy](./leetcode/easy/) - - [182. Duplicate Emails](./leetcode/easy/182.%20Duplicate%20Emails.sql) - [175. Combine Two Tables](./leetcode//easy/175.%20Combine%20Two%20Tables.sql) + - [181. Employees Earning More Than Their Managers](./leetcode/easy/181.%20Employees%20Earning%20More%20Than%20Their%20Managers.sql) + - [182. Duplicate Emails](./leetcode/easy/182.%20Duplicate%20Emails.sql) - [183. Customers Who Never Order](./leetcode/easy/183.%20Customers%20Who%20Never%20Order.sql) - [511. Game Play Analysis 1](./leetcode/easy/511.%20Game%20Play%20Analysis%201.sql) - [595. Big Countries](./leetcode/easy/595.%20Big%20Countries.sql) diff --git a/leetcode/easy/181. Employees Earning More Than Their Managers.sql b/leetcode/easy/181. Employees Earning More Than Their Managers.sql new file mode 100644 index 0000000..6f2adca --- /dev/null +++ b/leetcode/easy/181. Employees Earning More Than Their Managers.sql @@ -0,0 +1,31 @@ +/* +Question 181. Employees Earning More Than Their Managers +Link: +https://leetcode.com/problems/employees-earning-more-than-their-managers/description/ + +Table: Employee + ++-------------+---------+ +| Column Name | Type | ++-------------+---------+ +| id | int | +| name | varchar | +| salary | int | +| managerId | int | ++-------------+---------+ +id is the primary key (column with unique values) for this table. +Each row of this table indicates the ID of an employee, +their name, salary, and the ID of their manager. + + +Write a solution to find the employees who earn more +than their managers. + +Return the result table in any order. +*/ + +SELECT t1.name AS Employee +FROM Employee t1 +JOIN Employee t2 + ON t1.managerId = t2.id +WHERE t1.salary > t2.salary From b6ca08d13bbde4df2fc65ca150af46043343b746 Mon Sep 17 00:00:00 2001 From: ivanbyone Date: Sat, 28 Jun 2025 14:18:41 +0300 Subject: [PATCH 2/2] fix: lint --- .sqlfluff | 2 +- .../easy/181. Employees Earning More Than Their Managers.sql | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.sqlfluff b/.sqlfluff index c7b0e0c..43a374d 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,6 +1,6 @@ [sqlfluff] dialect = postgres -exclude_rules = LT01, CP02 +exclude_rules = LT01, LT05, CP02 [sqlfluff:rules] keywords_capitalisation_policy = upper diff --git a/leetcode/easy/181. Employees Earning More Than Their Managers.sql b/leetcode/easy/181. Employees Earning More Than Their Managers.sql index 6f2adca..94025fd 100644 --- a/leetcode/easy/181. Employees Earning More Than Their Managers.sql +++ b/leetcode/easy/181. Employees Earning More Than Their Managers.sql @@ -25,7 +25,8 @@ Return the result table in any order. */ SELECT t1.name AS Employee -FROM Employee t1 -JOIN Employee t2 +FROM Employee AS t1 +JOIN + Employee AS t2 ON t1.managerId = t2.id WHERE t1.salary > t2.salary