[HackerRank] SQL Basic (easy)(4)

2025. 8. 14. 17:30·코딩 테스트/02. SQL

1. Average Population

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

 

Average Population | HackerRank

Query the average population of all cities, rounded down to the nearest integer.

www.hackerrank.com

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

SELECT
    FLOOR(AVG(POPULATION)) AS AVG_POP
FROM CITY

2. Japan Population

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

 

Japan Population | HackerRank

Query to the sum of the populations of all Japanese cities in CITY.

www.hackerrank.com

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

SELECT
    SUM(POPULATION) AS JPN_TOTAL_POP
FROM 
    CITY
WHERE COUNTRYCODE = 'JPN'

3. Population Density Difference

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

 

Population Density Difference | HackerRank

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

www.hackerrank.com

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

SELECT MAX(POPULATION)- MIN(POPULATION) AS POP_DIFF
FROM CITY

4. Population Census

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

 

Population Census | HackerRank

Query the sum of the populations of all cities on the continent 'Asia'.

www.hackerrank.com

Given the CITY and COUNTRY tables, query the sum of the populations of all cities where the CONTINENT is 'Asia'.

SELECT 
	SUM(CITY.POPULATION) AS SUM_POP
FROM CITY
    JOIN COUNTRY 
    ON CITY.COUNTRYCODE = COUNTRY.CODE
WHERE COUNTRY.CONTINENT = 'Asia'

5. African Cities

https://www.hackerrank.com/challenges/african-cities/problem?isFullScreen=true

 

African Cities | HackerRank

Query the names of all cities on the continent 'Africa'.

www.hackerrank.com

Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is 'Africa'.

SELECT
    CITY.NAME
FROM COUNTRY
    JOIN CITY
    ON COUNTRY.CODE = CITY.COUNTRYCODE
WHERE
    COUNTRY.CONTINENT = 'Africa'

6. Average Population od Each Continent

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

 

Average Population of Each Continent | HackerRank

Query the names of all continents and their respective city populations, rounded down to the nearest integer.

www.hackerrank.com

 

Given the CITY and COUNTRY tables, query the names of all the continents (COUNTRY.Continent) and their respective average city populations (CITY.Population) rounded down to the nearest integer.

Note: CITY.CountryCode and COUNTRY.Code are matching key columns.

SELECT 
    COUNTRY.CONTINENT,
    FLOOR(AVG(CITY.POPULATION)) AS AVG_POP
FROM 
    COUNTRY
    JOIN CITY
    ON COUNTRY.CODE = CITY.COUNTRYCODE
GROUP BY COUNTRY.CONTINENT

'코딩 테스트 > 02. SQL' 카테고리의 다른 글

[Hacker Rank] SQL Basic (easy) (6)  (5) 2025.08.16
[HackerRank] SQL Basic (easy)(5)  (1) 2025.08.15
[HackerRank] SQL Basic (easy)(3)  (1) 2025.08.13
[HackerRank] SQL Basic (easy)(2)  (8) 2025.08.13
[HackerRank] SQL Basic (easy)(1)  (4) 2025.08.12
'코딩 테스트/02. SQL' 카테고리의 다른 글
  • [Hacker Rank] SQL Basic (easy) (6)
  • [HackerRank] SQL Basic (easy)(5)
  • [HackerRank] SQL Basic (easy)(3)
  • [HackerRank] SQL Basic (easy)(2)
Growth DA Log
Growth DA Log
Growth DA Log 님의 블로그 입니다.
  • Growth DA Log
    Growth DA Log님의 블로그
    Growth DA Log
  • 전체
    오늘
    어제
    • 분류 전체보기 (125)
      • TIS_COMPANY (6)
      • 코딩 테스트 (61)
        • 01. Python (3)
        • 02. SQL (58)
      • 데이터 분석 (53)
        • 01. BigQuery (9)
        • 02. GA4 (1)
        • 02-1. GA4를 더 잘 다루기 위한 마케팅 개.. (5)
        • 03. streamlit (5)
        • 04. Git (12)
        • 05. 데이터 엔지니어링 (3)
        • 06. 데이터 모델링 (11)
        • 07. Excel (0)
        • 08. Tableau (4)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    rank
    cross_join
    solvesql
    코테
    코딩테스트
    AARRR
    프로그래머스
    tableaubootcamp
    ROW_NUMBER
    윈도우함수
    이행성
    streamlit
    DENSE_RANK
    코드잇스프린트후기
    revert
    SQL
    tableau
    Reset
    git
    쿼리테스트
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.4
Growth DA Log
[HackerRank] SQL Basic (easy)(4)
상단으로

티스토리툴바