sql notes: hackerrank revising the select query 1

Problem


Query all columns for all American cities in CITY with populations larger than 100000. The CountryCode for America is USA.
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 columns ==> SELECT *
  • in CITY table ==> FROM CITY
  • populations larger than 100000 ==> POPULATION > 100000
  • CountryCode for America is USA ==> COUNTRYCODE = ‘USA’
  • American cities with populations larger than 100000 ==>
    WHERE COUNTRYCODE = ‘USA’ AND POPULATION > 100000

Solution


1
SELECT * FROM CITY WHERE COUNTRYCODE = 'USA' AND POPULATION > 100000;

Revising the Select Query 1
(中文版) SQL 笔记: Hackerrank Revising the Select Query 1