728x90
※ The EMPLOYEES table is described as follows:
( Salary is per month. )
( 1000 < SALARY < 10^5 )
■ [Aggregation] The Blunder
https://www.hackerrank.com/challenges/the-blunder/problem?isFullScreen=true
Q.
Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's 0 key was broken until after completing the calculation. She wants your help finding the difference between her miscalculation (using salaries with any zeros removed), and the actual average salary.
Write a query calculating the amount of error (i.e.: ACTUAL - MISCALCULATED average monthly salaries), and round it up to the next integer.
A.
SELECT CEIL( AVG( SALARY ) - AVG( TO_NUMBER(REPLACE(TO_CHAR(SALARY),'0','')) ) ) FROM EMPLOYEES;
반응형
'코딩 문제 풀기 ( Algorithm problem solving ) > 해커랭크 ( HackerRank )' 카테고리의 다른 글
[HackerRank][SQL(Oracle)] Type of Triangle (0) | 2023.03.29 |
---|---|
[HackerRank][SQL(Oracle)] Average Population of Each Continent, Population Census, African Cities (0) | 2023.03.27 |
[HackerRank][SQL(Oracle)] Employee Names, Employee Salaries, Top Earners (0) | 2023.03.27 |
[HackerRank][SQL(Oracle)] Higher Than 75 Marks (0) | 2023.03.27 |
[HackerRank][SQL(Oracle)] Weather Observation Station 13~20 (0) | 2023.03.26 |