We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I have the same problem. No matter where I put the ceiling function
SELECT cast(AVG(Salary)- CEILING( AVG(CAST(REPLACE(CAST(SALARY AS VARCHAR(5)),'0','') AS FLOAT))) AS INT) FROM Employees WHERE SALARY < 100000;
the result in not correct. The upper query returns 2251 which it says it's wrong.
So I did a little manual computing the total wrongly summurized salaries is 35890 which makes an avarage of 1794,5 (for 20 people) and if you compute the avarage salaries the right way then it is 4046. So based on this we only have one number where the rounding might be wrong is 1794,5.
So the possible answers should be 2251 or 2252, but both answers are wrong. What I am doing wrong??
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Blunder
You are viewing a single comment's thread. Return to all comments →
I have the same problem. No matter where I put the ceiling function
SELECT cast(AVG(Salary)- CEILING( AVG(CAST(REPLACE(CAST(SALARY AS VARCHAR(5)),'0','') AS FLOAT))) AS INT) FROM Employees WHERE SALARY < 100000;
the result in not correct. The upper query returns 2251 which it says it's wrong. So I did a little manual computing the total wrongly summurized salaries is 35890 which makes an avarage of 1794,5 (for 20 people) and if you compute the avarage salaries the right way then it is 4046. So based on this we only have one number where the rounding might be wrong is 1794,5.
So the possible answers should be 2251 or 2252, but both answers are wrong. What I am doing wrong??