Welcome to your interactive SQL laboratory, Almira! Write queries, see real-time visualizations, and master database skills through hands-on practice.
Results will appear here after you run a query.
View all students
SELECT * FROM students;
Find students from Berlin
SELECT name, age FROM students WHERE city = 'Berlin';
Find Almira's grades
SELECT students.name, grades.subject, grades.score FROM students JOIN grades ON students.id = grades.student_id WHERE students.name = 'Almira';
Average scores by subject
SELECT subject, AVG(score) as average_score FROM grades GROUP BY subject ORDER BY average_score DESC;
Column Name | Data Type | Description |
---|---|---|
id | INTEGER | Primary key |
name | TEXT | Student's name |
age | INTEGER | Student's age |
city | TEXT | City of residence |
grade | INTEGER | Grade level (e.g., 10) |
Column Name | Data Type | Description |
---|---|---|
id | INTEGER | Primary key |
student_id | INTEGER | Foreign key to students.id |
subject | TEXT | Subject name |
score | INTEGER | Score (0-100) |
Column Name | Data Type | Description |
---|---|---|
id | INTEGER | Primary key |
title | TEXT | Book title |
author | TEXT | Book author |
year | INTEGER | Publication year |
category | TEXT | Book category |
Basic SELECT:
SELECT column1, column2 FROM table_name;
Select all columns:
SELECT * FROM table_name;
Select with condition:
SELECT * FROM students WHERE age > 15;
Basic JOIN:
SELECT * FROM table1 JOIN table2 ON table1.id = table2.table1_id;
Example with our tables:
SELECT students.name, grades.subject, grades.score FROM students JOIN grades ON students.id = grades.student_id;
WHERE clause:
SELECT * FROM books WHERE year > 2010;
ORDER BY clause:
SELECT * FROM students ORDER BY name ASC;
LIMIT clause:
SELECT * FROM books LIMIT 5;
COUNT function:
SELECT COUNT(*) FROM students;
AVG function:
SELECT AVG(score) FROM grades;
GROUP BY clause:
SELECT subject, AVG(score) as avg_score FROM grades GROUP BY subject;