The Blunder

  • + 4 comments

    My Solution: SELECT CEIL(AVG(Salary)-AVG(REPLACE(Salary,'0',''))) FROM EMPLOYEES;

    Splitting into parts:
    CEIL: They asked to print the immediate next value. So used CEIL to get the next value....... REPLACE(Salary,'0',''): This will replace all the zeros with blank. Ex: 90780 will turn into 978...... AVG(Salary): Gives the Average total salary of all the employees...... AVG(REPLACE(Salary,'0','')): Gives the Average total salary of all the employees after removing zeros from the salaries...... (AVG(Salary)-AVG(REPLACE(Salary,'0',''))): This is the final difference which is asked in the question