Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- sql
- 선형 모형
- elastic net
- branch
- conflict
- mysql
- 교차 엔트로피
- RLIKE
- github
- HTML
- L2정규화
- 코딩공부
- full request
- 편향-분산 교환
- AWS
- CSS
- 온라인협업
- window function
- 버전충돌
- programmers
- coding
- early stopping
- 클라우드컴퓨팅
- PYTHON
- merge
- 깃헙협업
- leetcode
- hackerrank
- L1정규화
- Git
Archives
- Today
- Total
Im between cherry
Leet Code | MySQL | 185. Department Top Three Salaries 본문
185. Department Top Three Salaries
https://leetcode.com/problems/department-top-three-salaries/
The Employee table holds all employees. Every employee has an Id, and there is also a column for the department Id.
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 (order of rows does not matter).
# Write your MySQL query statement below
/* RANK(), DENSE_RANK() */
SELECT t.department
, t.employee
, t.salary
FROM(
SELECT department.name AS department
, employee.name AS employee
, employee.salary AS salary
, DENSE_RANK() OVER (PARTITION BY departmentid ORDER BY salary DESC) AS dr
FROM employee
INNER JOIN department ON employee.departmentid = department.id
)t
WHERE t.dr <= 3
'데이터분석 > practice_query' 카테고리의 다른 글
Leet Code | MySQL | 183. Customers Who Never Order (0) | 2020.08.30 |
---|---|
Leet Code | MySQL | 197. Rising Temperature (0) | 2020.08.30 |
Leet Code | MySQL | 184. Department Highest Salary (0) | 2020.08.30 |
Leet Code | MySQL | 180. Consecutive Numbers (0) | 2020.08.30 |
Leet Code | MySQL | 196. Delete Duplicate Emails (0) | 2020.08.30 |
Comments