Problem Description
Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN.
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 retrieve all columns from the CITY table, and apply a WHERE clause to filter for cities with the country code 'JPN'.
Step-by-Step Explanation
- Start with the SELECT statement to retrieve all columns:
SELECT *
- Specify the table to query from:
FROM CITY
- Add the WHERE clause to filter by country code:
WHERE COUNTRYCODE LIKE 'JPN'
- The final query:
SELECT
*
FROM
CITY
WHERE
COUNTRYCODE LIKE 'JPN';
Expected Output
The query will return all columns for cities in Japan (with COUNTRYCODE 'JPN').
Repo: https://github.com/mrpunkdasilva/hackerrank/tree/main/sql/basic/japansese-cities-names
Top comments (0)