You are viewing a single comment's thread. Return to all comments →
Like me, you may keep getting 2252 as the wrong answer (in DB2)
The solution is to use DECIMAL to perform the calculation using floats and then use INT on the total. You will then get the correct answer 2253.
SELECT INT(CEIL( AVG(DECIMAL(salary)) - AVG(DECIMAL(replace(char(salary), '0', ''))) )) FROM employees;
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 →
Like me, you may keep getting 2252 as the wrong answer (in DB2)
The solution is to use DECIMAL to perform the calculation using floats and then use INT on the total. You will then get the correct answer 2253.
SELECT INT(CEIL( AVG(DECIMAL(salary)) - AVG(DECIMAL(replace(char(salary), '0', ''))) )) FROM employees;