Employees Earning More Than Their Managers
you can give it an alias,this would be the header of your result :
No one has replied
Isn't the first way the old fashion and should be deprecated?
Because the question requires a difference column name as the output.
select E1.Name as Employee from Employee as E1, Employee as E2 where E1.ManagerId = E2.Id and E1.Salary > E2.Salary and E1.ManagerId IS NOT NULL
to check null you have to use IS or IS NOT
I just submitted it five times, got 1413, 1507, 1358, 1495 and 1310 ms. Looks like 1134 ms was a fluke.
Your URL doesn't work, as the underscores get misunderstood as markup. I think you can backslash-escape them, but better just make it an actual link.
Yes, everybody posts solutions as "questions" and many use the "solution-sharing" tag.
Your join condition is backwards. The managerId column indicates which employee manages that employee. So if Joe has managerId 3, Sam is his manager. It does not mean that Joe is manager #3
That makes sense actually if you think about it.
Id in Employee table might be the primary key, while Name column can simply contain duplicates. It's common for two employees to have the same first name.
"select id, name, salary from Employee where managerid is null"
Here you assume that no manager has a manager. There is nowhere in the question says this though.
I submit your solution and it take 1508ms
you need semicolon after your query.
I have tried, too slow!
select e1.Name Employee from Employee e1 inner join Employee e2 on e1.ManagerId = e2.Id where e1.Salary > e2.Salary
Disabled Categories are greyed out
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.