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.
you gotta use CEILING instead of FLOOR as it will round up the answer to next near integer and convert the entire answer into INT.
The average salaries should also be converted into float as SQL Server will only take the integer value while calculating the difference.
select convert(int, ceiling(avg(cast(salary as float)) - avg(cast(replace(salary,0,'') as float))))
from employees
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 →
you gotta use CEILING instead of FLOOR as it will round up the answer to next near integer and convert the entire answer into INT. The average salaries should also be converted into float as SQL Server will only take the integer value while calculating the difference.
select convert(int, ceiling(avg(cast(salary as float)) - avg(cast(replace(salary,0,'') as float)))) from employees