Problem Description
Query the NAME field for all American cities in the CITY table 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 |
Solution Approach
- Use a SELECT statement to query only the NAME column from the CITY table
- Apply a WHERE clause with two conditions:
- COUNTRYCODE = "USA" (cities in America)
- POPULATION >= 120000 (cities with populations larger than 120000)
Step-by-Step Explanation
- Start with the SELECT statement to retrieve only the NAME column:
SELECT NAME
- Specify the table to query from:
FROM CITY
- Add the WHERE clause with the required conditions:
WHERE COUNTRYCODE = "USA" AND POPULATION >= 120000
- The final query:
SELECT
NAME
FROM
CITY
WHERE
COUNTRYCODE = "USA" AND
POPULATION >= 120000
;
Expected Output
The query will return the names of all cities in the USA with populations greater than 120000.