Removing zeros from number

Here is the solution (MySQL) for Hackerrank challenge The Blunder

SELECT CEIL((AVG(salary)) - (AVG(REPLACE(salary, '0', '')))) AS avg_salary FROM employees;
  • REPLACE() : used to remove 0 from salary.
  • AVG() : used to calculate average salary.
  • CEIL() : used to get next rounded integer.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)