Snoopy [해커랭크/SQL] 28. The Blunder - replace 함수
코딩테스트/해커랭크 SQL

[해커랭크/SQL] 28. The Blunder - replace 함수

Sooyoon Jeong 2023. 3. 8.
 

 

🤔 문제 분석

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")

댓글