
Problem
Query the names of all American cities in CITY with populations larger than 120000. The CountryCode for America is USA.
Input Format
The CITY table is described as follows:
| Field | Type |
|---|---|
| ID | NUMBER |
| NAME | VARCHAR2(17) |
| COUNTRYCODE | VARCHAR2(3) |
| DISTRICT | VARCHAR2(20) |
| POPULATION | NUMBER |
Analysis
- query names ==> SELECT NAME
- in CITY table ==> FROM CITY
- populations larger than 120000 ==> POPULATION > 120000
- CountryCode for America is USA ==> COUNTRYCODE = ‘USA’
- American cities with populations larger than 120000 ==>
WHERE COUNTRYCODE = ‘USA’ AND POPULATION > 120000
Solution
|
|
Link
Revising the Select Query 2
(中文版) SQL 笔记: Hackerrank Revising the Select Query 2




近期评论