Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Greg Kaleka39,019 Points
A Simpler Solution to Which Teachers Don't Have a 1st Period Class
The EXCEPT solution is a good one. Just thought I'd share how I did it:
SELECT FIRST_NAME, LAST_NAME, MIN(PERIOD_ID) FROM TEACHERS JOIN CLASSES ON TEACHERS.ID = CLASSES.TEACHER_ID GROUP BY TEACHERS.ID HAVING MIN(PERIOD_ID) > 1
Guilherme Mergulhao4,002 Points
This is how I did it:
SELECT T.FIRST_NAME || ' ' || T.LAST_NAME AS FULLNAME, MIN(C.PERIOD_ID) AS FIRST_PERIOD FROM CLASSES AS C INNER JOIN TEACHERS AS T ON T.ID = C.TEACHER_ID GROUP BY FULLNAME HAVING FIRST_PERIOD > 1
SELECT * FROM TEACHERS WHERE id NOT IN (SELECT teacher_id FROM CLASSES WHERE period_id = 1)