The Blunder SQL- Hacker Rank Solution

The Blunder - Hacker Rank Solution
The Blunder – Hacker Rank Solution


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.

Input Format

The EMPLOYEES table is described as follows:

1443817108 adc2235c81 1

Note: Salary is per month.



Sample Input

1443817161 299cc6eb7f 2

Sample Output



The table below shows the salaries without zeros as they were entered by Samantha:

1443817229 eb00d44a3b 3

Samantha computes an average salary of . The actual average salary is .

The resulting error between the two calculations is . Since it is equal to the integer , it does not get rounded up.

The Blunder SQL – Hacker Rank Solution

SELECT CEIL(AVG(Salary)-AVG(REPLACE(Salary,'0','')))

Disclaimer: The above Problem (The Blunder) generated by Hackerrank but the Solution is Provided by Chase2Learn. This tutorial is only for Educational and Learning purposes. Authority if any of the queries regarding this post or website fill the following contact form thank you.

Leave a Comment