Query Examples
List of names and surnames of students whose surname starts with 'Nov', sorted by surname, then by name:
SELECT first_name, last_name FROM student
WHERE last_name LIKE 'Nov%' ORDER BY last_name, first_name;
List of IDs of students who are currently studying at the school with school=3
(order is random):
SELECT student_id FROM studies
WHERE school = 3 AND finished IS NULL;
List of students with the number of schools they have studied (or are studying):
SELECT student_id, MIN(last_name) AS last_name, COUNT(school) AS school_count
FROM student LEFT JOIN studies ON id_student = student_id
GROUP BY student_id;