Back to home
SQL programming language logo

SQLite Online Compiler

Practice SQLite right here — no installs, no signups.

SQLite Compiler
Output
Code runs on the Play with Coding execution engine — your code is saved locally for next time.

About the SQLite online compiler

SQL is how you ask a database questions. This online SQL compiler runs SQLite in your browser, so you can create tables, insert rows and query them without installing a database server — and the result set is printed as a table under the editor.

Practise SELECT with WHERE, ORDER BY and LIMIT, then aggregate with GROUP BY and HAVING, then join multiple tables. Joins are where most beginners stall, so the samples below start from two small tables you can retype from memory.

  • DBMS lab assignments without a local database
  • Practising JOIN types on tiny sample tables
  • Learning GROUP BY and aggregate functions
  • Testing a query's logic before running it in production

SQLite sample programs you can run right now

Copy any snippet into the editor above and press Run. Each one is short on purpose — retype it from memory afterwards.

Create, insert and select

CREATE TABLE students (id INTEGER, name TEXT, marks INTEGER);
INSERT INTO students VALUES (1, 'Aarav', 78), (2, 'Priya', 91), (3, 'Rohan', 55);

SELECT name, marks FROM students
WHERE marks > 60
ORDER BY marks DESC;

WHERE filters rows before grouping; ORDER BY sorts the final result.

A join with aggregation

CREATE TABLE courses (id INTEGER, student_id INTEGER, title TEXT);
INSERT INTO courses VALUES (1, 1, 'Python'), (2, 1, 'Java'), (3, 2, 'C++');

SELECT s.name, COUNT(c.id) AS total
FROM students s
LEFT JOIN courses c ON c.student_id = s.id
GROUP BY s.name;

LEFT JOIN keeps students with no courses; an INNER JOIN would drop them.

Common SQLite errors and how to fix them

no such table: students

Why: The CREATE TABLE statement was not run in the same session.

Fix: Keep the CREATE and INSERT statements above your SELECT in the same script.

misuse of aggregate function COUNT()

Why: An aggregate was used in WHERE.

Fix: Filter aggregates with HAVING, not WHERE.

ambiguous column name: id

Why: Both joined tables have that column.

Fix: Qualify it: s.id or c.id.

SQLite syntax cheatsheet

ConceptSyntax
Select rowsSELECT * FROM t WHERE x > 1;
Create tableCREATE TABLE t (id INTEGER, n TEXT);
InsertINSERT INTO t VALUES (1, 'a');
JoinFROM a JOIN b ON b.a_id = a.id
GroupGROUP BY col HAVING COUNT(*) > 1
UpdateUPDATE t SET n = 'b' WHERE id = 1;

SQLite compiler FAQs

Which SQL dialect is used?

SQLite, which covers the standard SELECT/INSERT/UPDATE/DELETE, joins and aggregates taught in most courses.

Is my data saved between runs?

No — each run starts with a fresh database, so include your CREATE and INSERT statements in the script.

Keep going after the compiler

Running snippets builds speed; the 17-chapter course builds understanding. Work through the SQLite chapters, take the quiz, then claim your certificate.

Other compilers: JavaScript compiler, TypeScript compiler, Python 3 compiler, Java compiler, C compiler, C++ compiler, Go compiler, Rust compiler, HTML compiler, CSS compiler

SQLite tutorial: five steps from blank editor to working program

These steps cover the queries you will write daily: selecting and filtering rows, sorting and limiting, aggregating with GROUP BY, joining tables, and modifying data safely.

  1. 1. SELECT and WHERE

    SELECT names the columns, FROM the table, WHERE the filter. Ask for the columns you need rather than * — it is clearer and faster.

    SELECT name, marks
    FROM students
    WHERE marks >= 50;
  2. 2. Sort and limit

    ORDER BY sorts (DESC for highest first) and LIMIT caps the row count. Together they answer every "top N" question.

    SELECT name, marks
    FROM students
    ORDER BY marks DESC
    LIMIT 5;
  3. 3. Aggregate with GROUP BY

    COUNT, SUM, AVG, MIN and MAX collapse many rows into one. Every non-aggregated column in the SELECT must appear in the GROUP BY, and HAVING filters the groups.

    SELECT subject, AVG(marks) AS avg_marks, COUNT(*) AS attempts
    FROM results
    GROUP BY subject
    HAVING COUNT(*) > 2
    ORDER BY avg_marks DESC;
  4. 4. Join related tables

    INNER JOIN keeps only matching rows; LEFT JOIN keeps every left-hand row and fills missing right-hand columns with NULL. Choosing between them is the most common SQL decision.

    SELECT s.name, c.title
    FROM students s
    LEFT JOIN certificates c ON c.student_id = s.id
    ORDER BY s.name;
  5. 5. Insert, update and delete carefully

    UPDATE and DELETE without a WHERE clause touch every row. Run the same condition as a SELECT first to see exactly what you are about to change.

    INSERT INTO students (name, marks) VALUES ('Diya', 91);
    
    UPDATE students SET marks = 95 WHERE name = 'Diya';
    
    DELETE FROM students WHERE marks IS NULL;

Practice exercises with solutions

Try each one in the editor above before opening the solution — the struggle is where the learning happens.

Beginner

List every student whose marks are between 40 and 60, sorted lowest first.

Hint: BETWEEN is inclusive on both ends.

Show solution
SELECT name, marks
FROM students
WHERE marks BETWEEN 40 AND 60
ORDER BY marks ASC;
Intermediate

Show each subject with its highest scorer's marks and how many students attempted it.

Hint: MAX and COUNT in the same grouped query.

Show solution
SELECT subject, MAX(marks) AS top_marks, COUNT(*) AS attempts
FROM results
GROUP BY subject
ORDER BY top_marks DESC;
Advanced

Rank students by marks within each subject.

Hint: A window function: RANK() OVER (PARTITION BY ... ORDER BY ...).

Show solution
SELECT subject, name, marks,
       RANK() OVER (PARTITION BY subject ORDER BY marks DESC) AS position
FROM results;

Why learn SQLite?

Almost every application stores its data in a relational database, so SQL is the shared language between developers, analysts and data scientists.

The core syntax barely changes across PostgreSQL, MySQL, SQLite and SQL Server, which makes it one of the most durable skills in software.

What SQLite is used for

  • Querying and reporting on application data
  • Data analysis and business dashboards
  • Backend development and schema design
  • Data engineering and ETL pipelines

Ready for structured practice? The 17-chapter SQLite course takes these ideas one at a time, with a quiz and a certificate at the end.