Tuesday, January 24, 2017

Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN

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:
 

My SQL query: 

SELECT name from CITY where COUNTRYCODE= 'JPN';

Query all columns for a city in CITY with the ID 1661

Query all columns for a city in CITY with the ID 1661.
Input Format
The CITY table is described as follows:



My SQL Query:
 select * from CITY where ID=1661;

Query all columns (attributes) for every row in the CITY table.

Query all columns (attributes) for every row in the CITY table.
Input Format
The CITY table is described as follows:






CITY.jpg

My SQL Query:
                   select * from CITY;

Weather Observation Station 4-Let be the number of CITY entries in STATION, and let be the number of distinct CITY names in STATION

Let be the number of CITY entries in STATION, and let be the number of distinct CITY names in STATION; query the value of from STATION. In other words, find the difference between the total number of CITY entries in the table and the number of distinct CITY entries in the table.
Input Format
The STATION table is described as follows:

where LAT_N is the northern latitude and LONG_W is the western longitude.

My SQL Query:

select count(CITY)-count(DISTINCT CITY) from STATION;