Skip to main content

Command Palette

Search for a command to run...

HackerRank: Revising the Select Query II

Published
1 min read

Problem:

https://www.hackerrank.com/challenges/revising-the-select-query-2

Question:

Code:

SELECT 
    NAME
FROM CITY
WHERE COUNTRYCODE='USA'
    AND POPULATION>120000

Key Points:

What the Query Does

  • Retrieves the names of U.S. cities

  • Only cities with population > 120,000 are included

Key Conditions Used

  • COUNTRYCODE = 'USA' → filters for American cities

  • POPULATION > 120000 → ensures only larger cities are selected

Why It Works

  • Only the NAME column is selected as required

  • The WHERE clause applies both conditions correctly — using AND

Output

  • List of qualifying city names (may return multiple rows)