AlgoMaster Logo

Exercise: SELECT Statement

Last Updated: May 10, 2026

1 min read

For this exercise, we will work with below data:

SQL

Exercise 1

Easy

Write a query that returns the title and duration_seconds of every track in the tracks table.

SQL

Expected Query

Expected Output

Exercise 2

Easy

From the artists table, return each artist's name aliased as artist_name and country aliased as country_code.

SQL

Expected Query

Expected Output

Exercise 3

Easy

Write a query against the tracks table that returns the title and a computed column duration_minutes showing duration in minutes as a decimal (use 60.0 to avoid integer division).

SQL

Expected Query

Expected Output

Exercise 4

Easy

Return every column from the albums table.

SQL

Expected Query

Expected Output

Exercise 5

Medium

From the artists table, return each artist's name and a computed column display_label that combines the name and country in the format "Name (CC)". Show 'Unknown' when country is NULL.

SQL

Expected Query

Expected Output

Exercise 6

Medium

From the tracks table, return track_idtitle, and a computed column catalog_code equal to album_id * 1000 + track_number. Order by catalog_code ascending.

SQL

Expected Query

Expected Output

Exercise 7

Medium

From the tracks table, return the title and a computed column duration_text that converts duration_seconds to a string by concatenating it with the literal ' seconds' (for example, '237 seconds').

SQL

Expected Query

Expected Output

Exercise 8

Hard

From the tracks table, return titleduration_seconds, integer minutes (duration_seconds / 60 aliased as minutes_int), and decimal minutes rounded to 2 decimal places (duration_seconds / 60.0 aliased as minutes_decimal). Order by duration_seconds ascending.

SQL

Expected Query

Expected Output