Free String Explorer: try Python and JavaScript string operations

Free SQL exercises with answers

Learn to turn a small table into the exact result a question asks for. These free SQL lessons and exercises cover selecting columns, naming output columns, preserving duplicate rows, and filtering records. They use SQLite and synthetic data in the browser.

No account needed for free previews · Hints, tests, and explained answers

Before you start: No previous SQL experience is required for these introductory previews. You should be comfortable reading a small table and following a written input/output contract. The full SQL course progresses to joins, aggregation, CTEs, windows, and reporting; those later topics are not all part of the free preview.

Worked example: filter rows without accidentally removing duplicates

Imagine a customers table with columns id and city, containing (1, Austin), (2, Dallas), (3, Austin), and (4, Austin). Return the city from rows whose id is at least 2, in id order.

SELECT city
FROM customers
WHERE id >= 2
ORDER BY id;
-- Result: Dallas, then Austin, then Austin

SELECT chooses the output column; WHERE chooses rows. ORDER BY makes the required sequence explicit. Without DISTINCT, repeated values remain separate rows. If a city appears twice in the selected rows, removing the duplicate would change the answer. NULL also needs care: use IS NULL or IS NOT NULL rather than equality with NULL.

How to practice with the examples and tests

Read the schema and supplied rows first. Write down the required column names, filters, duplicate behavior, and ordering. Submit one read-only result-producing query. Each test uses a fresh in-memory database, so one run does not modify the next. If a result fails, compare column aliases and repeated rows as well as the displayed values.

Choose your next free lesson or exercise

Start with SELECT and WHERE

Use the first two lessons to understand table/query contracts and precise filtering. Then practice customer names, an output-column alias, duplicate cities, paid-order filtering, and inclusive amount ranges.

Read a free lesson

Try free exercises with hints and solutions

See the full SQL for Real-World Data course outline →

Questions about free SQL practice

Which SQL database do the exercises use?

The browser runner uses SQLite through sql.js. Basic SELECT and WHERE concepts transfer to other SQL systems, but date functions, types, syntax, and some behaviors vary by database. These exercises follow the stated SQLite contract.

Do I need to install or connect a database?

No. The free exercise includes synthetic tables and rows in a fresh in-memory database for every test. No uploads, external database connection, or account is needed to try it.

Can I inspect answers and results?

Yes. Free exercises include hints, reference queries, explanations, and expected-versus-actual result tables. Read whether row order matters: unordered comparison still preserves duplicate rows. Sign in only if you want to save your progress.

Keep your progress when you are ready

Free previews are available without an account. An account lets you save your exercise code and progress. Create an account to save progress. Paid lessons and practice are clearly separated from these free links. Compare Course access, Practice Pack, and Complete Bundle.

Free lessons and coding exercises

Find a starting point, read a worked example, and try matching exercises with hints and solutions. No account is needed for free previews.

Read practical Python, JavaScript, and SQL tutorials →