Learning SQL by solving problem #4
Another problem from HackerRank website has been solved in this post. you can find all of the problems with their analysis and solutions in the SQL problems category.
Problem 4
Query all columns for a city in CITY table with the ID 1661.
Input Format
The CITY table is described as follows:
Field | TYPE |
ID | NUMBER |
NAME | VARCHAR2(17) |
COUNTRYCODE | VARCHAR2(3) |
DISTRICT | VARCHAR2(20) |
POPULATION | NUMBER |
Examination
“Query all columns” can be written as: SELECT *
“in CITY table” is going to be: FROM CITY
“city with ID 1661” can be translated to: WHERE ID = 1661
Code
SELECT * FROM CITY WHERE ID = 1661;