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 trialAhmed Mohamed Fouad
11,735 PointsMy Code for this lesson using CTE
WITH classes_ids AS (SELECT CLASS_ID FROM SCHEDULE
JOIN STUDENTS ON SCHEDULE.STUDENT_ID = STUDENTS.ID WHERE STUDENTS.FIRST_NAME = "Rex" AND STUDENTS.LAST_NAME = "Rios")
SELECT classes_ids.CLASS_ID AS Class, PERIODS.ID AS PERIOD, PERIODS.START_TIME AS "START TIME", PERIODS.DURATION AS DURATION, ROOMS.ID AS ROOM, SUBJECTS.NAME AS SUBJECT
FROM classes_ids
JOIN CLASSES ON classes_ids.CLASS_ID = CLASSES.ID
JOIN PERIODS ON CLASSES.PERIOD_ID = PERIODS.ID
JOIN ROOMS ON CLASSES.ROOM_ID = ROOMS.ID
JOIN SUBJECTS ON CLASSES.SUBJECT_ID = SUBJECTS.ID
ORDER BY PERIODS.ID;