Code of the Day
BeginnerQuerying basics

Lab: querying basics

Write real queries against the shop and have them checked instantly.

Lab · optionalSQLBeginner18 min
Recommended first
By the end of this lesson you will be able to:
  • Combine SELECT, WHERE, ORDER BY, and GROUP BY on real data
  • Write queries that pass an automatic result-set check

Optional lab. Write each query and hit Check — your result is compared against the correct one (right number of columns, right rows; order is only checked when the task asks for it). Everything runs on a real SQLite database in your browser. Use Run anytime to see your current output.

These three exercises use the shop dataset (customers, products, orders, order_items).

Checkpoint 1 — filter rows

Customers in the UK

Return the name of every customer whose country is the UK.

Remember: string values need single quotes'UK', not "UK".

Checkpoint 2 — filter and sort

Here order matters, so the check is strict about it.

Pricier products, most expensive first

Return the name and price of products costing more than 4, sorted from most to least expensive.

Checkpoint 3 — group and count

Customers per country

Return each country and how many customers it has (two columns: the country and the count).

Done?

Three green checks and you can read data fluently — filter, sort, and summarise. The intermediate track combines multiple tables with joins.

Finished reading? Mark it complete to track your progress.

On this page