top of page

Leetcode 185. Department Top 3 Salaries

  • crystal0108wong
  • Jun 1, 2017
  • 1 min read

Description

The Employee table holds all employees. Every employee has an Id, and there is also a column for the department Id. The Department table holds all departments of the company. Write a SQL query to find employees who earn the top three salaries in each of the department. For the above tables, your SQL query should return the following rows. [Read Full Description Here]

Solution

Thought Process

1. The same technique has been used before, pass the selected column as a 'constant' value into the sub-query whilst in the sub-query, perform command on the same table.

2. Find the salaries that has no more than 3 other salaries larger than it.

Comments


Featured Posts
Tag Cloud
Category

Crystal Wang @ 2017

bottom of page