Top Earner in Each Department
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Table departments:
id INTEGER primary key
name TEXT
Table employees:
id INTEGER primary key
name TEXT
salary INTEGER
department_id INTEGER never NULL
Return the highest-paid employee in each department. If several share the top salary, return all of them.
Columns, in this order: department name, employee name, salary.
Order by department name, then employee name.
A department with no employees does not appear.
Examples
Constraints
- Ties for the top salary are all returned.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.