-
-
Notifications
You must be signed in to change notification settings - Fork 99
Priyam2773 patch 3 #275
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Priyam2773 patch 3 #275
Conversation
Implement a function to retrieve the Nth highest salary from the Employee table.
Create function to get Nth highest salary
Add SQL query for second highest salary
|
🧙 Sourcery has finished reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for raising the PR, the owner will be review it soon' keep patience, keep contributing>>>!!! make sure you have star ⭐ the repo
PR Title Format: 181.EmployeesEarningMoreThanTheirManagers.cpp
🧠 Intuition
The problem requires identifying employees who earn more than their managers.
Each record in the Employee table contains id, name, salary, and managerId.
By comparing an employee’s salary with their manager’s salary, we can find those whose salary exceeds that of their manager.
💡 Approach
Self Join:
We perform a self join on the Employee table — one instance (e1) represents the employee, and the other (e2) represents the manager.
Join Condition:
We join both tables where the employee’s managerId matches the manager’s id.
Filter Condition:
We then use a WHERE clause to filter only those employees whose salary is greater than their manager’s salary.
Select Output:
Finally, we select the employee’s name as the output column Employee.
✅ Code Solution (C++ / SQL)
SELECT e1.name AS Employee
FROM Employee e1
JOIN Employee e2 ON e1.managerId = e2.id
WHERE e1.salary > e2.salary;
🔗 Related Issues
Closes #181
By submitting this PR, I confirm that:
This is my original work not totally AI generated
I have tested the solution thoroughly on LeetCode
I have maintained proper PR description format
This is a meaningful contribution, not spa
Summary by Sourcery
Scaffold directories for LeetCode SQL problems 176 and 177 and add the Employees Earning More Than Their Managers (#181) SQL solution
New Features: