이 영역을 누르면 첫 페이지로 이동
쿄코코 블로그의 첫 페이지로 이동

쿄코코

페이지 맨 위로 올라가기

쿄코코

얼레벌레 생활🤯

Revising Aggregations - Averages,Average Population,Japan Population,Population Density Difference,The Blunder

  • 2022.09.17 04:51
  • SQL/HackerRank
    반응형

    Revising Aggregations - Averages📝

    https://www.hackerrank.com/challenges/revising-aggregations-the-average-function/problem?isFullScreen=true 

    ➡️ city 테이블 

    • population 평균 구하기 -> AVG 함수 활용 
    • district 이 'california' 
     

    Query the average population of all cities in CITY where District is California. 

    Input Format

    The CITY table is described as follows:

    SELECT AVG(population)
    FROM city
    WHERE district='california';

     


     

    Average Population📝

    https://www.hackerrank.com/challenges/average-population/problem?isFullScreen=true 

    ➡️ city 테이블 

    • population 평균 구하기( 정수형태로 표현) -> AVG 함수, ROUND 함수 활용

    Query the average population for all cities in CITY, rounded down to the nearest integer.

    Input Format

    The CITY table is described as follows:

    SELECT ROUND(AVG(population))
    FROM city;

     


     

    Japan Population📝

    https://www.hackerrank.com/challenges/japan-population/problem?isFullScreen=true 

    ➡️ city 테이블 

    • population 합계 구하기 -> SUM 함수
    • countrycode='JPN'
     

     Query the sum of the populations for all Japanese cities in CITY. The COUNTRYCODE for Japan is JPN.

    Input Format

    The CITY table is described as follows:

    SELECT SUM(population)
    FROM city
    WHERE countrycode='JPN';

     


     

    Population Density Difference📝

    https://www.hackerrank.com/challenges/population-density-difference/problem?isFullScreen=true&h_r=next-challenge&h_v=zen 

    ➡️ city 테이블 

    • population 최댓값과 최솟값의 차이 구하기 -> MAX,MIN 함수 사용

    Query the difference between the maximum and minimum populations in CITY.

    Input Format

    The CITY table is described as follows:

    SELECT MAX(population)-MIN(population)
    FROM city;

     


     

    The Blunder📝

    https://www.hackerrank.com/challenges/the-blunder/problem?isFullScreen=true 

    ➡️ employees 테이블 

    • (salary의 평균값)과  (salary 0글자를 없애고 난 후에 평균값)의 차 -> salary의 0글자를 REPLACE 함수로 대체
    • 그 다음 큰 integer 값을 구하라고 함 ( 가우스 함수 ) -> CELING 함수를 사용하여 소수점이 있을 경우 올림하기

    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.

    Input Format

    The EMPLOYEES table is described as follows:

    Note:  Salary is per month. 

    Constraints

    . 

    Sample Input

    Sample Output

    2061
    

    Explanation

    The table below shows the salaries without zeros as they were entered by Samantha:

    Samantha computes an average salary of . The actual average salary is .

    The resulting error between the two calculations is . Since it is equal to the integer , it does not get rounded up.

    SELECT CEILING(AVG(salary)-AVG(REPLACE(salary,'0','')))
    FROM employees;

     

    반응형

    'SQL > HackerRank' 카테고리의 다른 글

    Weather Observation Station 16,17,18,19 | Population Census  (0) 2022.10.24
    HackerRank - Top Earners,Weather Observation Station 2, 13, 14, 15  (1) 2022.10.03
    Employee Salaries,Type of Traingle,The PADS,Revising Aggregations - (The Count Function,The Sum Function)  (0) 2022.09.12
    HackerRank- Weather Observation Station 10,11,12,Higher Than 75 Marks,Employee Names  (0) 2022.09.12
    HackerRank- Weather Observation Station 6,7,8,9  (0) 2022.09.04

    댓글

    이 글 공유하기

    • 구독하기

      구독하기

    • 카카오톡

      카카오톡

    • 라인

      라인

    • 트위터

      트위터

    • Facebook

      Facebook

    • 카카오스토리

      카카오스토리

    • 밴드

      밴드

    • 네이버 블로그

      네이버 블로그

    • Pocket

      Pocket

    • Evernote

      Evernote

    다른 글

    • Weather Observation Station 16,17,18,19 | Population Census

      Weather Observation Station 16,17,18,19 | Population Census

      2022.10.24
    • HackerRank - Top Earners,Weather Observation Station 2, 13, 14, 15

      HackerRank - Top Earners,Weather Observation Station 2, 13, 14, 15

      2022.10.03
    • Employee Salaries,Type of Traingle,The PADS,Revising Aggregations - (The Count Function,The Sum Function)

      Employee Salaries,Type of Traingle,The PADS,Revising Aggregations - (The Count Function,The Sum Function)

      2022.09.12
    • HackerRank- Weather Observation Station 10,11,12,Higher Than 75 Marks,Employee Names

      HackerRank- Weather Observation Station 10,11,12,Higher Than 75 Marks,Employee Names

      2022.09.12
    다른 글 더 둘러보기

    정보

    쿄코코 블로그의 첫 페이지로 이동

    쿄코코

    • 쿄코코의 첫 페이지로 이동

    검색

    메뉴

    • 홈

    카테고리

    • 분류 전체보기 (172)
      • Python (24)
        • 😈 99클럽 코테 스터디 4기 TIL (23)
        • 궁금한거 정리 (1)
      • SQL (16)
        • HackerRank (15)
      • [백준] Python,Java로 풀기📖 (71)
        • 정렬(Sorting) (6)
        • 그리디 (5)
        • 문자열 (7)
        • 수학 (3)
        • DFS&BFS (10)
        • 구현 (4)
        • 다이나믹 (17)
        • 이분탐색 (1)
        • 자료구조 (10)
        • 최단거리 (5)
        • 인덱스트리 (0)
      • [프로그래머스]Python,Java로 풀기 (6)
        • Level 1 (4)
        • Level 2 (2)
      • Study Platform📚 (28)
        • 김영한👨🏻‍🏫의 스프링 부트와 JPA 실무 완전 .. (5)
        • (알고리즘)- [이코테] 이것이 코딩테스트다 정리 (10)
        • 그림으로 배우는 Http&Network Basic (10)
        • AWS SAA C03공부하기 (3)
      • 까먹을까봐 적는 것들 (5)
      • 테스트 보고 난 후..🤔 (0)
      • kt 에이블스쿨 (18)

    최근 글

    인기 글

    댓글

    공지사항

    아카이브

    태그

    • 항해99
    • TiL
    • 99클럽
    • 프로그래머스
    • 오블완
    • 티스토리챌린지
    • 코딩테스트준비
    • 백준

    나의 외부 링크

    정보

    쿄코코의 쿄코코

    쿄코코

    쿄코코

    블로그 구독하기

    • 구독하기
    • RSS 피드

    방문자

    • 전체 방문자
    • 오늘
    • 어제

    티스토리

    • 티스토리 홈
    • 이 블로그 관리하기
    • 글쓰기
    Powered by Tistory / Kakao. © 쿄코코. Designed by Fraccino.

    티스토리툴바