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.