AlgoMaster Logo

Exercise: Table and Column Aliases

Last Updated: May 10, 2026

1 min read

For this exercise, we will work with below data:

SQL

Exercise 1

Easy

Select username aliased as name and subscription_tier aliased as plan from the users table. Order by name.

SQL

Expected Query

Expected Output

Exercise 2

Easy

Write a query that joins albums and artists using table aliases al and ar. Return al.title aliased as album_title and ar.name aliased as artist_name. Order by album_title.

SQL

Expected Query

Expected Output

Exercise 3

Medium

Write a query using single-letter table aliases for users (u) and streams (s) that returns username and minutes_listened (rounded to one decimal) for streams longer than 3 minutes. Order by minutes_listened descending, then username.

SQL

Expected Query

Expected Output

Exercise 4

Medium

From the streams table, return stream_idduration_listened, and a column length_category that is 'short' if duration is under 200 seconds, 'medium' if 200-299, and 'long' for 300+. Order by stream_id.

SQL

Expected Query

Expected Output