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.: average monthly salaries), and round it up to the next integer.
Answers
Answered by
2
Answer:
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.
Answered by
2
QUERY for Calculating the amount of error can be written as follows,
SELECT
ROUND(AVG(SALARY)) -
ROUND(AVG(REPLACE(SALARY, '0','')))
FROM EMPLOYEES;
Explanation:
SELECT statement returns the selected data from a database.
ROUND function returns the value rounded to a specific number.
AVG is an aggregate function that returns the average value.
REPLACE functions replaces the value of a particular sub string with a new value of a sub string.
Similar questions
Math,
5 months ago
Math,
5 months ago
Environmental Sciences,
11 months ago
Geography,
11 months ago