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.
- Prepare
- SQL
- Aggregation
- The Blunder
- Discussions
The Blunder
The Blunder
Sort by
recency
|
2023 Discussions
|
Please Login in order to post a comment
WITH REFINED_TABLE AS ( SELECT *, REGEXP_REPLACE(SALARY,0,"") AS NAKED_SALARY FROM EMPLOYEES ) SELECT CEIL(AVG(SALARY) - AVG(NAKED_SALARY)) AS DIFF FROM REFINED_TABLE
select cast(avg(salary) as SIGNED) - cast(avg(replace(salary,'0','')) as SIGNED) from EMPLOYEES ;
Simple query for mysql workbench user;
SELECT CEIL(AVG(Salary) - AVG(CAST(REPLACE(CAST(Salary AS CHAR), '0', '') AS UNSIGNED))) AS error_amount FROM EMPLOYEES; MySQL
MySQL :
SELECT CEIL((SELECT AVG(salary) FROM EMPLOYEES) - (SELECT AVG(CAST(REPLACE(Salary,'0','')AS UNSIGNED)) FROM EMPLOYEES)) As amount_of_error;