일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Numpy
- FullyConnectedLayer
- Word2vec
- select
- PPMI
- backward
- dl
- Sigmoid
- sort
- stak
- 신경망
- skip-gram
- Stack
- Programmers
- hash
- DeepLearning
- 프로그래머스
- 파이썬
- 자연어처리
- boj
- que
- CBOW
- affine
- algorithm
- SQL
- Python
- 딥러닝
- MySQL
- kakao
- Heap
- Today
- Total
혜온의 이것저것
[HackerRank] The Blunder (MySQL) 본문
문제
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 zeros 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: Salary is per month.
Constraints
1000 < Salary < 10^5.
Sample Input
Sample Output
2061
Explanation
The table below shows the salaries without zeros as they were entered by Samantha:
Samantha computes an average salary of 98.00. The actual average salary is 2159.00.
The resulting error between the two calculations is 2159.00-98.00=2061.00. Since it is equal to the integer 2061, it does not get rounded up.
풀이
select ceil(avg(salary)-avg(replace(salary,0,'')))
from employees
'Data Analysis > SQL' 카테고리의 다른 글
[HackerRank] Weather Observation Station 2 (MySQL) (0) | 2022.08.15 |
---|---|
[HackerRank] Top Earners (MySQL) (0) | 2022.08.15 |
[HackerRank] Population Density Difference (MySQL) (0) | 2022.08.15 |
[HackerRank] Japan Population (MySQL) (0) | 2022.08.12 |
[HackerRank] Average Population (0) | 2022.08.12 |