HackerRank – Select By ID

HackerRank SQL Problem 4 – Difficulty: Easy

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:

FieldTYPE
IDNUMBER
NAMEVARCHAR2(17)
COUNTRYCODEVARCHAR2(3)
DISTRICTVARCHAR2(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;

Leave a Reply

Your email address will not be published. Required fields are marked *