AlgoMaster Logo

Exercise: BETWEEN and IN

Last Updated: May 10, 2026

1 min read
SQL

Exercise 1

Easy

From the tracks table, find every track whose duration_seconds is between 180 and 300 inclusive. Return title and duration_seconds, ordered by duration_seconds ascending.

SQL

Expected Query

Expected Output

Exercise 2

Easy

From the users table, find every user whose country is 'US''GB', or 'JP'. Return username and country, ordered by username ascending.

SQL

Expected Query

Expected Output

Exercise 3

Medium

From the users table, find every user from 'US''GB', or 'JP' who signed up in 2024 (between 2024-01-01 and 2024-12-31 inclusive). Return usernamecountry, and signup_date.

SQL

Expected Query

Expected Output

Exercise 4

Medium

From the tracks table, find every track whose album_id is in (1, 3, 5) AND whose duration_seconds is between 200 and 250 inclusive. Return titlealbum_id, and duration_seconds.

SQL

Expected Query

Expected Output

Exercise 5

Hard

rom the users table, find every user whose signup_date is in 2023 (between 2023-01-01 and 2023-12-31 inclusive) AND whose country is NOT in ('US''KR'). Return usernamecountry, and signup_date, ordered by signup_date ascending.

SQL

Expected Query

Expected Output

Exercise 6

Hard

Using the users and artists tables, find every user whose country does NOT appear in the artists table. Return username and country.

SQL

Expected Query

Expected Output