Revising the Select Query I Solution
Hello Friends in this article i am gone to share Hacker Rank SQL Solutions with you. | Revising the Select Query I Solution
Also visit this link: Print Prime Numbers Solution
Revising the Select Query I
Task
Query all columns for all American cities in the CITY table with populations larger than 100000. The Country Code for America is USA.
The CITY table is described as follows:
Field | Type |
ID | NUMBER |
NAME | VARCHAR2(17) |
COUNTRYCODE | VARCHAR2(3) |
DISTRICT | VARCHAR2(20) |
POPULATION | NUMBER |
Solution – Revising the Select Query I
MYSQL Code
SELECT * FROM CITY WHERE COUNTRYCODE = 'USA' AND POPULATION > 100000;
Easiest way to solve SQL Revising the Select Query I
Explaination:
The solution is easy and straight forward.
Sql Statement:
select * from CITY where COUNTRYCODE=’USA’ and POPULATION>=100000;
- The question says to select all cities where country code is USA and whose population is more than 100000,So we use Select * from city to select all cities from the table.
- Now we give a condition mentioning that we want only those cities whose country code is USA and the population must be greater than or atleast equal to 1 lakh i.e 100000
- Finally we run the query to check the outcomes , here is what we get.
Disclaimer: The above Problems are generated by Hacker Rank but the Solutions are Provided by NYANDER.COM. All Hacker Rank SQL Solutions Shared only for Educational and Learning Purpose.