How to use the online SQL editor
- 1Pick an example from the chips above the editor, or type your own query.
- 2Press Run SQL or Ctrl/Cmd + Enter. Multiple statements separated by ; run in order.
- 3Results appear as tables with row counts and execution time.
- 4Browse the schema panel to see every table, column and primary key. Click a table name to preview it.
- 5Experiment freely with INSERT, UPDATE, DELETE or CREATE TABLE — click Reset database to start fresh.
Sample database schema
The practice database models a small college and its staff:
- departments (dept_id, dept_name, location)
- students (student_id, name, email, city, dept_id → departments, year, cgpa)
- courses (course_id, title, dept_id → departments, credits, fee)
- enrollments (enrollment_id, student_id → students, course_id → courses, grade, enrolled_on)
- employees (emp_id, name, role, dept_id → departments, salary, manager_id → employees, hired_on)
SQL commands you can practise
SELECT … WHERE … ORDER BY
Filter and sort rows
GROUP BY + COUNT/SUM/AVG/MIN/MAX
Summarise data
INNER / LEFT JOIN
Combine related tables
HAVING & subqueries
Filter groups and nest queries
INSERT / UPDATE / DELETE
Change data
CREATE TABLE / DROP TABLE
Define and remove tables
Example: top student in each department
This query joins students to departments and uses a correlated subquery to find the highest CGPA per department:
SELECT d.dept_name, s.name, s.cgpa FROM students s JOIN departments d ON d.dept_id = s.dept_id WHERE s.cgpa = ( SELECT MAX(cgpa) FROM students WHERE dept_id = s.dept_id ) ORDER BY s.cgpa DESC;
Copy it into the editor and run it. Then try changing MAX to MIN, or add WHERE d.location = 'Block A'.
Why practise SQL here
- Zero setup — no database installation, accounts or downloads.
- Safe sandbox: nothing you run can affect real data.
- Realistic relational data for interview and placement test practice.
- Helpful error messages that suggest the right table name when you make a typo.