Im between cherry

Hackerrank | MySQL | The Blunder 본문

데이터분석/practice_query

Hackerrank | MySQL | The Blunder

meal 2020. 8. 28. 09:40

The Blunder

Problem

 

The Blunder | HackerRank

Query the amount of error in Sam's result, rounded up to the next integer.

www.hackerrank.com

Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's  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.

 

SELECT CEIL(AVG(salary)-AVG(REPLACE(salary,0,'')))
FROM employees
Comments