Problem Statement: 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 zeros removed), and the actual average salary.
Write a query calculating the amount of error (i.e.: average monthly salaries), and round it up to the next integer.
The EMPLOYEES table is described as follows:
Note: Salary is per month.
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.
For this challenge, we have to use three functions round(), avg(), and replace().
Let's see in the below Query.
Query:
Select round(avg(salary))-round(avg(replace(salary, '0', ''))) from Employees;