Editor

Online SQL compiler

Write SQL against a sample database or your own tables and see each result as a table.

Students of classes 11 and 12, their teachers, the courses they teach, and each student's enrollments with marks.

-- Each student's average mark, best first
SELECT s.name, s.class, s.section, ROUND(AVG(e.marks), 1) AS average
FROM students s
JOIN enrollments e ON e.student_id = s.id
GROUP BY s.id
ORDER BY average DESC
LIMIT 10;

Press Run to see the result. Changes to the database last until you press Reset or reload the page.

Practise with problems

The SQL practice problems use these databases: write the query, press Check, and see whether it returns the right rows.

The sample databases

School

Students of classes 11 and 12, their teachers, the courses they teach, and each student's enrollments with marks.

  • courses: id, name, teacher_id, credits
  • enrollments: id, student_id, course_id, marks, enrolled_on
  • students: id, name, gender, class, section, city, dob, email
  • teachers: id, name, subject, city, joined_on

Online shop

Customers from many countries, the products the shop sells, their orders across 2025 and 2026, and the items in each order.

  • customers: id, name, city, country, signup_date, phone
  • order_items: id, order_id, product_id, quantity, unit_price
  • orders: id, customer_id, order_date, status
  • products: id, name, category, price, stock

Company

Departments in several cities, the employees in them with their managers and salaries, projects, and the hours people spend on each project.

  • assignments: id, employee_id, project_id, hours
  • departments: id, name, location
  • employees: id, name, department_id, manager_id, job_title, salary, hire_date
  • projects: id, name, department_id, budget, start_date, end_date

MySQL and SQLite: what to write here

ToMySQLSQLite (here)
List the tablesSHOW TABLES;SELECT name FROM sqlite_master WHERE type = 'table';
Describe a tableDESC students;PRAGMA table_info(students);
Join textCONCAT(name, ' ', city)name || ' ' || city
Auto-numbered keyid INT AUTO_INCREMENT PRIMARY KEYid INTEGER PRIMARY KEY
Today's dateCURDATE()date('now')
Year of a dateYEAR(hire_date)strftime('%Y', hire_date)
First rowsLIMIT 5LIMIT 5 (the same)

Questions

Is my SQL sent to a server?

No. The database lives in your browser, so your queries and tables never leave this page.

Which SQL does it run?

SQLite 3, the database built into Python and most phones. Standard SELECT, JOIN, GROUP BY, subqueries, WITH and window functions all work; the table above shows where MySQL differs.

Can I create my own tables?

Yes. Pick Empty database, then CREATE TABLE and INSERT your rows. Changes last until you press Reset database or reload the page; keep your SQL with Copy link.

Can I use the result in Python?

Run it from Python opens the editor with the same database and query in Python, using sqlite3 and pandas, so you can go on to charts and analysis.