The Blunder

  • + 0 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