sql notes: hackerrank japanese cities’ attributes

Problem


Query all attributes of every Japanese city 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 all attributes ==> SELECT *
  • in the CITY table ==> FROM CITY
  • COUNTRYCODE for Japan is JPN ==> COUNTRYCODE = ‘JPN’
  • Japanese city ==> WHERE COUNTRYCODE = ‘JPN’

Solution


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

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