SELECT d.Name As Department, E1.Name As Employee, E1.Salary FROM Employee E1 INNER JOIN Department d ON E1.DepartmentId = d.Id WHERE 3 > (SELECT COUNT (DISTINCT (E2.Salary)) FROM Employee E2 WHERE E2.DepartmentId = E1.DepartmentId AND E2.Salary > E1.Salary);
Can any one find the error of my solution? I feel I almost exactly copied someone's right answer (which I tested and passed), but still not correct.
Please help, thanks!
Remove the space after
(Also, to help others help you, please include input/output/error. Well, since this is a syntax error, the error would've sufficed.)
Thank you! That's really it! I'm quite new to SQL and didn't know that it's so strict with space. I will take your advice to include error next time. Thank you again!
I actually didn't know it's so strict, either :-)
I btw copy&pasted it into the MySQL Workbench on my PC, which helped a lot to locate the problem ... it red-underlined the
I was just curious - are you actually able to debug leetcode SQL problems on your MySQL Workbench? Don't you need to do a lot of work like set up appropriate tables, insert rows, etc.?
I'm asking since I find debugging SQL on leetcode very tedious since they don't accept custom test cases. Thanks!
I actually don't remember... I do SQL problems so rarely. But I think I did create a table with some rows once. In this case it wasn't necessary, though, as the workbench showed me the syntax error without needing the table.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.