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.
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
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 →
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