SQL Compiler Playground - Interactive Database Practice

Practise SQL without installing a database. This compiler runs real database operations against sample datasets, so you can execute SELECT, JOIN, aggregation, and other queries and see the results immediately.

Open the SQL playground

Tip: use the playground in full screen
The playground is easier to use in full screen. It fills the whole window, and on a computer the schema, the question, your query and the results sit side by side, so you can read the task, write your answer and check the result without scrolling up and down. To switch it on, click the full screen button at the top right of the playground, next to the practice question list (on a phone it is the button labelled "Full screen"). To go back, press Esc or click the same button again.
Real Databases
Practice with sample datasets that mimic real-world database structures
Instant Results
Get immediate feedback with formatted result tables and execution time
Guided Practice
100 practice questions across 20 SQL topics, from first SELECT to window functions

How to Use the SQL Compiler

Step 1: Explore the Schema

Click the "Schema" button to view database tables and their structure. Each table shows:

  • Table names: Identifies each database table
  • Column names: Shows what data each table contains
  • Data types: INTEGER, VARCHAR, DATE, etc.
  • Relationships: Primary and foreign key connections

Step 2: Load Practice Questions (Optional)

Pick a topic, a difficulty level and a question. Every topic has 5 questions (2 beginner, 2 intermediate, 1 advanced), and each one tells you exactly which columns to return, the rules to apply and how to sort the result. Topics covered:

  • Basics: SELECT, WHERE, ORDER BY and LIMIT, IN / BETWEEN / LIKE, NULL values
  • Summarising: aggregate functions, GROUP BY, HAVING, CASE expressions
  • Combining tables: INNER, LEFT and self joins, UNION / INTERSECT / EXCEPT
  • Advanced: subqueries, EXISTS, CTEs and recursive CTEs, string and date functions, window functions

Step 3: Write or Edit SQL

Type SQL queries in the editor. Example queries:

SELECT * FROM employees LIMIT 10;
SELECT department, COUNT(*) FROM employees GROUP BY department;
SELECT e.name, d.name FROM employees e JOIN departments d ON e.dept_id = d.id;

Tip: Remember to end each query with a semicolon (;)

Step 4: Execute and View Results

Click "Run Query" to execute your SQL. Results appear in the right panel showing:

  • Formatted result table with all columns and rows
  • Execution time to understand query performance
  • Row count to verify expected results
  • Error messages if the query fails (with debugging tips)

Popular SQL Queries to Practice

Basic SELECT

Retrieve all data from a table or filter rows with WHERE clauses to find specific records.

JOINs

Combine data from multiple tables using INNER, LEFT, RIGHT, and FULL JOINs for related data.

Aggregations

Calculate totals with SUM, COUNT, AVG, MIN, MAX grouped by categories with GROUP BY.

Subqueries

Nest SELECT statements to create complex queries for advanced data filtering and analysis.

Data Filtering

Use WHERE, BETWEEN, IN, LIKE operators to filter results based on multiple conditions.

ORDER & LIMIT

Sort results with ORDER BY and limit output with LIMIT for pagination and top-N queries.

SQL Query Best Practices for QA

Always use explicit JOINs

Use INNER, LEFT, or RIGHT JOIN instead of implicit joins for clarity and correctness

Specify columns in SELECT

Avoid SELECT *. Name specific columns for better performance and clarity about what data you need

Use aliases for clarity

Apply table and column aliases (AS) to make complex queries readable and self-documenting

Filter early with WHERE

Use WHERE clauses before JOINs and aggregations to reduce data processed and improve performance

Understand NULL handling

Remember NULL is not equal to anything including NULL. Use IS NULL and IS NOT NULL for proper comparisons

Test edge cases

Always verify your queries handle NULL values, empty results, duplicates, and boundary conditions

Frequently Asked Questions

What databases are available in this compiler?

The playground includes sample databases with realistic data structures for practicing SELECT, JOIN, aggregation, and filtering queries. Data is reset regularly for fresh practice.

Can I modify the database structure?

This playground is read-only and focused on SELECT queries. For learning INSERT, UPDATE, DELETE, and CREATE TABLE statements, practice on a local MySQL or PostgreSQL database.

How do I debug a failed query?

Check the error message in results panel. It usually indicates if there's a syntax error, missing column, or incorrect table name. Review the schema panel to verify exact table and column names.

Why is my query running slowly?

Check the execution time in results. Slow queries usually have missing indexes or process too much data. Try filtering with WHERE clauses earlier and avoid SELECT * on large tables.

Can I use this for real database testing?

This is great for learning SQL syntax and query patterns. For actual QA database testing, connect to your application's test database or staging environment with proper credentials and data.

Ctrl + Enter to run
Results

Run a query to see results