HackerRank SQL — All Details of American Cities with Population Over 100000

Published: (March 29, 2026 at 09:35 AM EDT)
1 min read
Source: Dev.to

Source: Dev.to

Solution

The task is to retrieve all columns for American cities with a population greater than 100,000.

SELECT *
FROM CITY
WHERE COUNTRYCODE = 'USA'
  AND POPULATION > 100000;
  • SELECT * returns every column from the CITY table.
  • The WHERE clause applies two conditions combined with AND: the city must be in the United States (COUNTRYCODE = 'USA') and its population must exceed 100,000.

This query builds on basic SELECT and WHERE concepts, combining them to filter the desired rows.

0 views
Back to Blog

Related posts

Read more »

CA 40 - Alter Tables

Practice ALTER TABLE Statements 1. Make Email NOT NULL customers sql ALTER TABLE customers MODIFY email VARCHAR100 NOT NULL; Result: email becomes a required f...

Basic Select SQL Queries

'HackerRank SQL Practice Question 1 Task: Query all columns for a city in CITY with the ID 1661. Solution: sql SELECT FROM CITY WHERE ID = 1661;

Alter Tables

1. Make the email column NOT NULL in customers sql ALTER TABLE customers ALTER COLUMN email SET NOT NULL; 2. Ensure username is unique in users sql ALTER TABLE...

Alter Queries

In this assignment, I worked on modifying existing tables using ALTER TABLE. This helped me understand how to update constraints without recreating tables. Task...