RUN

SQL Online Compiler

Write and run SQL queries in your browser. Results as tables, free, no sign-up.

main.sql

-- Welcome to the CodingHumans SQL compiler (SQLite).
-- Press Run (or Ctrl + Enter). Every run starts with an empty database.

CREATE TABLE employees (
  id INTEGER PRIMARY KEY,
  name TEXT NOT NULL,
  department TEXT,
  salary INTEGER
);

INSERT INTO employees (name, department, salary) VALUES
  ('Asha', 'Engineering', 95000),
  ('Rohan', 'Engineering', 82000),
  ('Mei', 'Design', 70000),
  ('Karan', 'Sales', 64000),
  ('Priya', 'Design', 76000);

SELECT department, COUNT(*) AS people, AVG(salary) AS avg_salary
FROM employees
GROUP BY department
ORDER BY avg_salary DESC;
Output

Press Run to see the output.

SQL examples to try

How to run SQL online

  1. Create your tables and insert some rows, or start from an example.
  2. Write SELECT queries below them.
  3. Press Run, or Ctrl + Enter (Cmd + Enter on a Mac). Each SELECT shows a table of results.
  4. Press Share to copy a short link to your queries. Anyone who opens it sees exactly what you wrote.

About this SQL compiler

This free SQL compiler runs SQLite (version 3) directly in your browser. Write CREATE TABLE, INSERT and SELECT statements together, press Run, and every SELECT shows its result as a table.

Every run starts with a fresh, empty database, so you can try things without breaking anything. Joins, GROUP BY and HAVING, subqueries, common table expressions (WITH) and window functions such as RANK() and ROW_NUMBER() all work.

If a statement has a mistake, the error tells you which line it is on, and the statements before it still show their results.

Frequently asked questions

›Is this SQL compiler free?

Yes. It is free with no sign-up and no run limits. The database runs in your own browser, which is what keeps it free.

›Is it MySQL, PostgreSQL or SQLite?

It is SQLite. Standard SQL such as SELECT, JOIN, GROUP BY, subqueries and window functions works the same as in MySQL and PostgreSQL, so it is good for practising queries. A few things differ, for example AUTO_INCREMENT (use INTEGER PRIMARY KEY) and some date functions.

›Is my data saved?

Each run starts with an empty database, so put your CREATE TABLE and INSERT statements above your queries. Your SQL itself is saved in this browser, and Share gives you a link to it.

›Why do I only see some results?

Only statements that return rows, such as SELECT, show a table. CREATE, INSERT, UPDATE and DELETE run silently. Large results show the first 1,000 rows.

›Can I practise SQL interview questions here?

Yes. Try the examples, such as the second highest salary, joins and window functions, then change them to answer your own questions.