SQL Practice Exercises

Try four short challenges using the café’s drinks table. Write down your query before revealing the answer.

Use this sample table

drinks
namecategoryprice
Espressocoffee3.00
Lattecoffee4.50
Matcha Lattetea5.25
Chai Lattetea4.75

1. List all drink names

Return a single column with every drink’s name.

Show the SELECT answer
SELECT name FROM drinks;

The result has one column and four rows. Without ORDER BY, the row order is unspecified.

2. Find the teas

Return the names and prices of drinks in the tea category.

Show the WHERE answer
SELECT name, price
FROM drinks
WHERE category = 'tea';

The matching drinks are Matcha Latte and Chai Latte.

3. Sort by price

List every drink and its price from cheapest to most expensive.

Show the ORDER BY answer
SELECT name, price
FROM drinks
ORDER BY price ASC;

Espresso comes first, followed by Latte, Chai Latte, and Matcha Latte.

4. Find the most expensive tea

Combine filtering, sorting, and a row limit to return one result.

Show the LIMIT answer
SELECT name, price
FROM drinks
WHERE category = 'tea'
ORDER BY price DESC, name ASC
LIMIT 1;

The query returns Matcha Latte. Sorting by name after price makes the result predictable if two drinks tie on price.

Try your first interactive lesson

Practice selecting columns in your browser and get immediate feedback.

Start the free SQL lesson