🙏 We need your help! SQLtest.online has no ads and lives only on donations. Even a small amount helps. Donate now →
SQL code copied to buffer
Task 25:

View of Free Seats per Section

MariaDB
The registration page shows how many seats are left in each section. The task runs on small copies of courses, sections (with max_capacity) and enrollments.
Create the view v_section_seats with the columns section_id, code (the course code), max_capacity, enrolled (the number of enrollments with the status enrolled) and seats_left (max_capacity minus enrolled). Every section must be in the view, including a section without students (0 enrolled).
Expected result Columns: 6 · Rows: 4
object_type section_id code max_capacity enrolled seats_left

Write your query below and click "Check it!". Tables are described in the right pane.

Tutorial

By checking a query, you agree that it is stored without your account details and may be included in anonymized datasets, including for AI training. Learn more

The query result will appear here. Ctrl+Enter - Run query