Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases SQL Reporting by Example Day 2: Advanced Selecting Student Schedule

My solution

-- Generate a schedule for Rex Rios.

SELECT period_id AS "Period", name AS "Subject", room_id AS "Room", first_name || ' ' || last_name AS "Teacher" FROM Schedule
JOIN Classes ON Classes.id = Schedule.class_id
JOIN Subjects ON Subjects.id = Classes.subject_id
JOIN Teachers ON Teachers.id = Classes.teacher_id
WHERE student_id IN (
  SELECT id FROM Students
  WHERE first_name LIKE 'Rex'
  AND last_name LIKE 'Rios'
)
ORDER BY period_id;