SQL chapters

Chapter 17 of 17

Build a small study report

Try this in our SQLite Compiler →

The idea

Finish with a database exercise containing students and study sessions. Choose stable keys, join explicitly, aggregate by the intended entity, and order the final report. Keep every sample self-contained. SQL dialect knowledge is as important as remembering keyword names.

Worked example

WITH sessions(student, minutes) AS (VALUES ('Asha', 20), ('Asha', 25), ('Ravi', 30))
SELECT student, sum(minutes) AS total_minutes FROM sessions GROUP BY student ORDER BY total_minutes DESC, student;

What to check

Asha totals 45 minutes and Ravi totals 30. The query is a report, not proof of learner activity on this website.

Practice task

Create your own two-table study report with a LEFT JOIN for students with no sessions. Test known rows and empty data before taking the separate assessment.

Check your understanding

Explain the result in your own words before changing the example. Change one thing at a time, compare the result with your prediction, and keep the version that demonstrates the concept clearly.

Try it yourself

Output
Run your project to see output here.
Ctrl/Cmd+Enter runs · Ctrl/Cmd+S downloads the project · Local auto-save is always on