일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- NLP
- airflow
- LSTM
- GRU
- CASE
- SQL 날짜 데이터
- 자연어처리
- sql
- nlp논문
- 자연어 논문 리뷰
- leetcode
- 논문리뷰
- 그룹바이
- SQL코테
- MySQL
- t분포
- HackerRank
- torch
- 설명의무
- 표준편차
- 카이제곱분포
- inner join
- 코딩테스트
- update
- 짝수
- Statistics
- 서브쿼리
- Window Function
- 자연어 논문
- sigmoid
- Today
- Total
HAZEL
[SQL : HackerRank/Leetcode] INNER JOIN 본문
1. African Cities
>> 문제
Given the CITY and COUNTRY tables, query the names of all cities where the CONTINENT is 'Africa'.
Note: CITY.CountryCode and COUNTRY.Code are matching key columns.
Input Format
The CITY and COUNTRY tables are described as follows:
>> 문제 푼 코드
select city.NAME
from city
INNER JOIN COUNTRY ON CITY.CountryCode = COUNTRY.CODE
WHERE COUNTRY.CONTINENT = 'Africa'
www.hackerrank.com/challenges/african-cities/problem?h_r=internal-search
2. Asian Population
>> 문제
Given the CITY and COUNTRY tables, query the sum of the populations of all cities where the CONTINENT is 'Asia'.
Note: CITY.CountryCode and COUNTRY.Code are matching key columns.
Input Format
The CITY and COUNTRY tables are described as follows: 위 문제의 테이블과 같다.
>> 문제 푼 코드
SELECT SUM(CITY.population)
FROM CITY
INNER JOIN COUNTRY ON CITY.CountryCode = COUNTRY.CODE
WHERE CONTINENT = 'Asia'
www.hackerrank.com/challenges/asian-population/problem
3. Average Population of Each Continent
+) 그룹바이와 INNER JOIN 을 함께 연산
>> 문제
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.
Input Format
The CITY and COUNTRY tables are described as follows: 위 문제의 테이블과 같다.
>> 문제 푼 코드
SELECT COUNTRY.CONTINENT , FLOOR(AVG(CITY.POPULATION))
FROM CITY
INNER JOIN COUNTRY ON COUNTRY.CODE = CITY.COUNTRYCODE
GROUP BY COUNTRY.CONTINENT
'DATA ANALYSIS > SQL' 카테고리의 다른 글
[SQL : HackerRank] UNION (0) | 2021.02.14 |
---|---|
[SQL : HackerRank/Leetcode] SELF JOIN (0) | 2021.02.13 |
[SQL : Leetcode] LEFT JOIN 문 (0) | 2021.02.13 |
[SQL : GROUP BY/ where 서브쿼리 ] HackerRank: Top Earners (0) | 2021.02.12 |
[SQL : HackerRank/Leetcode] CASE 문 (0) | 2021.02.08 |