๐ข ๋ณธ ํฌ์คํ ์ ํ์ฉ๋๋ ๊ธฐ๋ณธ ๋ฌธ์ ๋ฐ ์๋ฃ ์ถ์ฒ๋ HackerRank ์์ ๋ฐํ๋๋ค.
โ ๋ฌธ์
https://www.hackerrank.com/challenges/the-blunder/problem?isFullScreen=true
Samantha was tasked with calculating the average monthly salaries for all employees in the EMPLOYEES table, but did not realize her keyboard's 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.
Input Format
The EMPLOYEES table is described as follows:
Note: Salary is per month.
โ ํ์ด
SELECT CEIL(avg(Salary)-avg(REPLACE(Salary,0,'')))
FROM EMPLOYEES;
0 ๋ฒํผ์ด ๊ณ ์ฅ๋์ ์ง์๋ค ์๊ธ์์ ์ซ์ 0์ด ๋ค ๋น ์ ธ๋ฒ๋ ธ๋ค๋ ... ์์ฐ ..
์ค์ ์ ์ฒด ์ง์ ์๊ธ์ ํ๊ท ๊ณผ ์๋ชป ๊ณ์ฐ๋ ์๊ธ ํ๊ท ์ ์ฐจ์ด๋ฅผ ๊ตฌํ๊ณ ,์ฐจ์ด๋ฅผ ์ฌ๋ฆผํ๋ ๊ฐ์ ์ถ์ถํ๋ ์ฟผ๋ฆฌ๋ฅผ ๋ง๋๋ ๋ฌธ์
์๊ธ์ ํ๊ท ๊ตฌํ๊ธฐ > avg ์ฌ์ฉ0์ด ๋น ์ก๋ค > 0์ ๊ณต๋ฐฑ์ผ๋ก ๋์ฒด - replace(s1, s2, s3) ํจ์ ์ฌ์ฉ๊ฒฐ๊ณผ๊ฐ ์ฌ๋ฆผ ์ฒ๋ฆฌ > ceil ์ฌ์ฉ
'Growth ๐ณ > Practice ๐ป' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Hacker Rank] Weather Observation Station 16 (0) | 2022.08.22 |
---|---|
[Hacker Rank] Weather Observation Station 14 (0) | 2022.08.22 |
[SQL] ์ฐ์ต๋ฌธ์ (0) | 2022.08.03 |
[Hacker Rank] Weather Observation Station 20 : MySQL (0) | 2022.08.02 |
[ํด์ปค๋ญํฌ] Weather Observation Station 5 (0) | 2022.07.28 |