DEV Community

Cover image for HackerRank SQL Preparation: Revising the Select Query I(MySQL)
Christian Paez
Christian Paez

Posted on

3

HackerRank SQL Preparation: Revising the Select Query I(MySQL)

Problem Statement:
Query all columns for American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA.

Link:HackerRank - Revising the SELECT Query

Solution:

SELECT * FROM CITY WHERE POPULATION > 100000 AND COUNTRYCODE = 'USA';
Enter fullscreen mode Exit fullscreen mode

Explanation:
This SQL query retrieves all columns () for cities in the **CITY* table where the population is greater than 100000 and the CountryCode is 'USA'. Here's a breakdown of each part:

  • SELECT *: Selects all columns from the CITY table.
  • FROM CITY: Specifies the table from which to retrieve data, which is the CITY table in this case.
  • WHERE POPULATION > 100000: Filters the rows to include only cities with a population larger than 100000.
  • AND COUNTRYCODE = 'USA': Further narrows down the selection to cities located in America (USA) based on the CountryCode column.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more