Pavithra's Space
  • Home
  • Skills
    • SQL
    • HackerRank
      • Revising the Select Query I
      • Revising the Select Query II
      • Select All
      • Select By ID
      • Japanese Cities' Attributes
      • Japanese Cities' Names
      • Weather Observation Station 1
      • Weather Observation Station 3
      • Weather Observation Station 4
      • Weather Observation Station 5
      • Weather Observation Station 6
      • Weather Observation Station 7
      • Weather Observation Station 8
      • Weather Observation Station 9
      • Weather Observation Station 10
      • Weather Observation Station 11
      • Weather Observation Station 12
      • Higher Than 75 Marks
      • Employee Names
      • Employee Salaries
Powered by GitBook
On this page
  1. Skills
  2. HackerRank

Revising the Select Query II

PreviousRevising the Select Query INextSelect All

Last updated 1 year ago

Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA.

The CITY table is described as follows:

Solution:

SELECT NAME FROM CITY WHERE population>120000 AND CountryCode = "USA";

Explanation:

  • SELECT NAME: This part of the query specifies that we only want to retrieve the names of the cities.

  • FROM CITY : This tells us that we're looking in the CITY table for the data.

  • WHERE population>120000: This condition filters the cities based on their population, only selecting those with populations greater than 120,000.

  • AND CountryCode = "USA" : This is another condition added to the WHERE clause. It specifies that we only want cities with the country code "USA".

Revising the Select Query II | HackerRankHackerRank
Logo