DEV Community

Mr Punk da Silva
Mr Punk da Silva

Posted on

Hackerrank - SQL - Select All

Problem Description

Query all columns (attributes) for every row in the CITY table.

Input Format

The CITY table is described as follows:

Field Type
ID NUMBER
NAME VARCHAR2(17)
COUNTRYCODE VARCHAR2(3)
DISTRICT VARCHAR2(20)
POPULATION NUMBER

Solution Approach

Use a simple SELECT statement with the asterisk (*) wildcard to retrieve all columns from the CITY table.

Step-by-Step Explanation

  1. Start with the SELECT statement and use the asterisk (*) to select all columns:
   SELECT *
Enter fullscreen mode Exit fullscreen mode
  1. Specify the table to query from:
   FROM CITY;
Enter fullscreen mode Exit fullscreen mode
  1. The final query:
   SELECT
   *
   FROM CITY;
Enter fullscreen mode Exit fullscreen mode

Expected Output

The query will return all rows from the CITY table, displaying all columns (ID, NAME, COUNTRYCODE, DISTRICT, POPULATION) for each city in the database.

Top comments (0)