Learn SQL by solving problem #2
I am going to analyze the HackerRank #2 challenge for SQL in this post. You can find all of these problems in the SQL Problems category. If you are just familiar with the basic concepts of SQL, you can improve your skill by solving these problems.
Problem 2
Query the names of all American cities in CITY with populations larger than 120000. The CountryCode for America is the USA.
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 the names” can translate into: SELECT NAME
“in CITY table” can translate into: FROM CITY
“populations larger than 120000” can translate into: POPULATION > 120000
“CountryCode for America is USA” can translate into: COUNTRYCODE = ‘USA’
So “American cities with populations larger than 120000” leads to: WHERE COUNTRYCODE = ‘USA’ AND POPULATION > 120000
Code
The final solution can be as follows:
SELECT NAME FROM CITY WHERE COUNTRYCODE = 'USA' AND POPULATION > 120000;
Howdy I am so grateful I found your webpage, I really found you by mistake,
while I was looking on Aol for something else, Anyhow I am here now and would just like to say thanks for a remarkable
post and a all round enjoyable blog (I also love the theme/design), I don’t have time
to look over it all at the minute but I have
bookmarked it and also included your RSS feeds, so when I have time I will be back to read a great deal more,
Please do keep up the excellent jo.
Here is my web blog … Buy CBD
Hi, I would like to subscribe for this weblog to obtain most recent updates, therefore where can i do it please assist. Deeanne Alessandro Lambrecht
There is definately a great deal to find out about this subject. I love all the points you made. Elyn Alberik Alten
I was studying some of your articles on this website and I conceive this site is real instructive! Continue putting up. Nadiya Donavon Thagard
I love the efforts you have put in this, thanks for all the great posts. Phebe Parrnell Bodkin
I truly appreciate this article post. Much obliged. Charity Harp Gil
You made some decent points there. I looked on the internet for the issue and found most individuals will agree with your site. Faydra Cornelius Sparhawk
Incredible points. Outstanding arguments. Keep up the good work. Lynne Rudiger Jacintha
You are my aspiration , I possess few blogs and infrequently run out from to brand. Sherri Dean Wohlert
Excellent pieces. Keep writing such kind of information on your blog. Birgit Durante Ailis
Hi there to every one, the contents existing at this website are actually awesome for people experience, well, keep up the nice work fellows. Robin Tobias Ivers
I am truly happy to glance at this webpage posts which includes plenty of helpful facts, thanks for providing these kinds of data. Deerdre Durand Bianca
There is definately a lot to learn about this topic. I really like all of the points you have made. Lydie Aldin Hadley