sql notes: hackerrank japanese cities’ names

Problem


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:

CITY

Field Type
ID NUMBER
NAME VARCHAR2(17)
COUNTRYCODE VARCHAR2(3)
DISTRICT VARCHAR2(20)
POPULATION NUMBER

Analysis


  • query the names ==> SELECT NAME
  • in the CITY table ==> FROM CITY
  • COUNTRYCODE for Japan is JPN ==> COUNTRYCODE = ‘JPN’
  • Japanese cities ==> WHERE COUNTRYCODE = ‘JPN’

Solution


1
SELECT NAME FROM CITY WHERE COUNTRYCODE = 'JPN';

Japanese Cities’ Names
(中文版) SQL 笔记: Hackerrank Japanese Cities’ Names