diff --git a/.sqlfluff b/.sqlfluff index 752ca1c..43a374d 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,7 +1,7 @@ [sqlfluff] dialect = postgres -exclude_rules = LT01, CP02 +exclude_rules = LT01, LT05, 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..94025fd --- /dev/null +++ b/leetcode/easy/181. Employees Earning More Than Their Managers.sql @@ -0,0 +1,32 @@ +/* +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 AS t1 +JOIN + Employee AS t2 + ON t1.managerId = t2.id +WHERE t1.salary > t2.salary