일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- hackerrank
- Machine Learning Advanced
- Segmentation
- 파이썬
- 코딩테스트
- Python
- 튜토리얼
- 나는 리뷰어다
- 협업필터링
- 한빛미디어
- Recsys-KR
- MySQL
- DilatedNet
- 스택
- pytorch
- DFS
- 입문
- TEAM EDA
- 3줄 논문
- 알고리즘
- TEAM-EDA
- 큐
- 추천시스템
- 프로그래머스
- 엘리스
- Object Detection
- Image Segmentation
- 나는리뷰어다
- Semantic Segmentation
- eda
- Today
- Total
TEAM EDA
[HackerRank] Basic Aggregation : The Blunder 본문
Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's 0 key was broken until after completing the calculation. She wants your help finding the difference between her miscalculation (using salaries with any zeroes removed), and the actual average salary.
Write a query calculating the amount of error (i.e.:actual - miscalculated average monthly salaries), and round it up to the next integer.
Input Format
The EMPLOYEES table is described as follows:
Note : Salaryis measured in dollars per month and its value is < 10^5.
Sample Input
Sample Output
2061
Explanation
The table below shows the salarieswithout zeroesas they were entered by Samantha:
Samantha computes an average salary of 98.00. Theactualaverage salary is 2159.00
The resulting error between the two calculations is 2159.00 - 98.00 = 2061.00 which, when rounded to the next integer, is. 2061
풀이
SELECT CEIL(AVG(Salary) - AVG(REPLACE(Salary, 0, ''))) FROM EMPLOYEES
'EDA Study > SQL' 카테고리의 다른 글
[HackerRank] Basic Aggregation : Weather Observation Station (0) | 2021.02.09 |
---|---|
[HackerRank] Basic Aggregation : Top Earners (0) | 2021.02.09 |
[HackerRank] Basic Aggregation : Revising Aggregations (0) | 2021.02.09 |
[HackerRank] Basic Join : Top Competitors (0) | 2021.02.08 |
[HackerRank] Basic Join : The Report (2) | 2021.02.08 |