In This Post we will see the Revising the Select Query 2 HackerRank Solution
The Question:
We have to query the Name column and get the data from CITY table for all
American Cities whose population count is more than 120000.
Information Provided In the Question:
CountryCode="USA"
Population Count= 120000
Table Schema:
Solution for Revising the Select Query 2 HackerRank Question:
It is a beginner level SQL question that is used to tests our knowledge of
where clause with and operator.
Quick note: Where clause is used to filter records and AND Operator is
used to filter with more than 1 conditions.
Approach:
To select just the name column we will use "NAME" instead of general "*"
that is used to select all columns of the tables.
Use the WHERE clause with AND operator.
First filter will be on the Country Code, and Second filter will be on the
population.
SQL Statement:
SELECT NAME FROM CITY WHERE COUNTRYCODE="USA" AND POPULATION > 120000
Result:
Conclusion:
In this post we have successfully solved the Revising the Select Query 2
Hackerrank Question. And we have seen the use of WHERE clause with AND
operator.
Also See:
Please Let me Know, If you have any doubts.
Please Let me Know, If you have any doubts.