HackerRank【SQL1】
The CITY table is described as follows:
1、Revising the Select Query I
Query all columns for all American cities in CITY with populations larger than 100000
. The CountryCode for America is USA
.
SELECT * FROM CITY WHERE COUNTRYCODE = 'USA' AND POPULATION > 100000;
2、Revising the Select Query II
Query the names of all American cities in CITY with populations larger than 120000
. The CountryCode for America is USA
.
SELECT NAME FROM CITY WHERE COUNTRYCODE = 'USA' AND POPULATION > 120000;
3、Select All
Query all columns (attributes) for every row in the CITY table.
select * from CITY;
4、Select By ID
Query all columns for a city in CITY with the ID 1661
.
select * from CITY where ID = '1661';
5、Japanese Cities' Attributes
Query all attributes of every Japanese city in the CITY table. The COUNTRYCODE for Japan is JPN
.
select * from CITY where COUNTRYCODE = 'JPN';
6、Japanese Cities' Names
Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN
.
select name from CITY where COUNTRYCODE = 'JPN';