일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 빅데이터
- 공부정리
- 위대한 수업
- ADP
- CNN10
- 코테
- 조지프 나이
- K-MOOC
- MySQL
- 백준
- 누가 진정한 리더인가
- Progate
- Hacker Rank
- Great Minds
- 당신이 몰랐던 진화론
- Udemy
- 맛집
- Baekjoon
- 알고리즘
- python
- 데이터분석전문가가이드
- Joseph Samuel Nye Jr.
- 자료구조
- 후기
- 미분적분학
- EBS
- 정치학
- ADsP
- KMOOC
- 데이터분석전문가
Archives
- Today
- Total
ㅇ
[Hacker Rank_MySQL]문제 풀이#Top Earners 본문
SQL > Aggregation > Top Earners
Top Earners | HackerRank
Find the maximum amount of money earned by any employee, as well as the number of top earners (people who have earned this amount).
www.hackerrank.com
We define an employee's total earnings to be their monthly salary * months worked, and the maximum total earnings to be the maximum total earnings for any employee in the Employee table. Write a query to find the maximum total earnings for all employees as well as the total number of employees who have maximum total earnings. Then print these values as 2 space-separated integers.
빨간 글씨는 내가 문제를 풀 때 중요하다고 생각한 부분이다.
SELECT MAX(SALARY * MONTHS), COUNT(*)
FROM EMPLOYEE
WHERE SALARY * MONTHS = (SELECT MAX(SALARY * MONTHS) FROM EMPLOYEE)
아래는 디스커션에서 참고한 내용으로, 순서대로 나열해서 한 개만 택하는 방식이다.
SELECT (SALARY * MONTHS) AS earnings, COUNT(*)
FROM EMPLOYEE
GROUP BY earnings
ORDER BY earnings DESC
LIMIT 1
반응형
'IT > 코테문제' 카테고리의 다른 글
[Hacker Rank_MySQL]문제 풀이#The PADS (0) | 2022.03.01 |
---|---|
[Hacker Rank_MySQL]문제 풀이#Challenges (0) | 2022.03.01 |
[Hacker Rank_MySQL]문제 풀이#Ollivander's Inventory (0) | 2022.02.27 |
[Hacker Rank_MySQL]문제 풀이#Top Competitors (0) | 2022.02.27 |
[Hacker Rank_MySQL]문제 풀이#The Report (0) | 2022.02.23 |
Comments