| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
- 알고리즘
- Hackerrank
- 코드스테이츠
- 역행자
- 코딩공부
- 개발자_조이킴
- Where
- 재귀함수
- Programmers
- for문
- 배열
- select
- JavaScript
- 코딩테스트
- Algorithms
- Developer_JoyKim
- array.push()
- 자바스크립트
- array
- 정규표현식
- array.slice()
- 블록체인
- 코플릿
- MySQL
- node.js
- 개발자의 책장
- SQL
- join
- 프로그래머스
- 최강의 인생
- Today
- Total
CodingSpace
[HackerRank/SQL] Revising Aggregations - The Blunder 본문
Problem. Revising Aggregations - The Blunder
Link.
https://www.hackerrank.com/challenges/the-blunder/problem?isFullScreen=true
Population Density Difference | HackerRank
Query the difference between the maximum and minimum city populations in CITY.
www.hackerrank.com
Description.
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.: average monthly salaries), and round it up to the next integer.

Key Point.
SELECT,
AVG,
REPLACE,
CEIL, CEIL()함수는 부동 소수점을 올림해서 반환하는 함수
- ex#1 - SELECT CEIL(0.5); → 1
- ex#2 - SELECT CEIL(0.1); → 1
- ex#3 - SELECT CEIL(-1.3); → -1
My Answer.
SELECT CEIL(AVG(Salary) - AVG(REPLACE(Salary, '0', '')))
FROM EMPLOYEES;
References.
MYSQL - CEIL() 함수
무료로 사용할 수 있는 CMS 형 PHP 버드 패널, 테마, FTP 외 라이브러리 제공
www.habonyphp.com
'HackerRank > SQL' 카테고리의 다른 글
| [HackerRank/SQL] Aggregation - Japan Population (0) | 2022.07.19 |
|---|---|
| [HackerRank/SQL] Revising Aggregations - Top Earners (0) | 2022.07.19 |
| [HackerRank/SQL] Revising Aggregations - Population Density Difference (0) | 2022.07.17 |
| [HackerRank/SQL] Revising Aggregations - Averages (0) | 2022.07.16 |
| [HackerRank/SQL] Revising Aggregations - Average Population (0) | 2022.07.14 |