https://www.hackerrank.com/challenges/revising-the-select-query-2/problem
Revising the Select Query II | HackerRank
Query the city names for all American cities with populations larger than 120,000.
www.hackerrank.com
Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA.
The CITY table is described as follows:
[풀이]
1. CITY 테이블에서 값을 조회할 것으므로 FROM절에 CITY 작성
2. NAME 컬럼을 조회할 것이므로 SELECT절에 NAME 작성
3. 조회할 값의 조건은 POPULATION 컬럼의 값이 120000보다 크고, COUNTRYCODE가 USA인 컬럼이다. 두 조건을 모두 만족해야하므로 AND로 두 조건을 연결할 것이다. 우선 POPULATION 컬럼의 값이 120000보다 큰 것은 POPULATION>120000로 표현, COUNTRYCODE가 USA인 것은 COUNTRYCODE = "USA"로 표현한다.
WHERE POPULATION > 120000 AND COUNTRYCODE = "USA"
[코드]
SELECT NAME
FROM CITY
WHERE POPULATION > 120000 AND COUNTRYCODE = "USA"
'SQL > HackerRank' 카테고리의 다른 글
[HackerRank/SQL] Binary Tree Nodes (0) | 2021.11.07 |
---|---|
[HackerRank/SQL] The PADS (0) | 2021.11.06 |
[HackerRank/SQL] Weather Observation Station 19 (0) | 2021.10.31 |
[HackerRank/SQL] Weather Observation Station 18 (0) | 2021.10.30 |
[HackerRank/SQL] Revising the Select Query I (0) | 2021.10.30 |