🤔 문제 분석
1) 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.
2) Write a query calculating the amount of error (i.e.: average monthly salaries), and round it up to the next integer.
💡 풀이
SELECT CEILING(AVG(SALARY) - AVG(REPLACE(SALARY, 0, "")))
FROM EMPLOYEES
REPLACE(문자열, "old", "new")
'코딩테스트 > 해커랭크 SQL' 카테고리의 다른 글
[해커랭크/SQL] 30. Weather Observation Station 2 (0) | 2023.03.12 |
---|---|
[해커랭크/SQL] 29. Top Earners (0) | 2023.03.08 |
[해커랭크/SQL] 27. Population Density Difference (0) | 2023.03.07 |
[해커랭크/SQL] 26. Japan Population (0) | 2023.03.07 |
[해커랭크/SQL] 25. Average Population (0) | 2023.03.07 |
댓글