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 trialabdel ahbe
Python Development Techdegree Student 1,959 PointsI believe the solution provided in the video is not correct!
the grade info is stored in STUDENTS Table which is not joined. Also the query may provide list of teacher teaching other grades and not only 8 ( like 8 and 7).
with my solution below I found different result set:
SELECT DISTINCT t.FIRST_NAME, t.LAST_NAME, st.GRADE FROM TEACHERS AS t INNER JOIN CLASSES AS c ON C.TEACHER_ID = t.ID INNER JOIN SCHEDULE AS sc ON c.ID = sc.CLASS_ID INNER JOIN STUDENTS AS st ON st.ID = sc.STUDENT_ID WHERE st.GRADE = 8
ORDER BY t.FIRST_NAME;
I am still not sure how to eliminate teacher who teach 8th grade plus other grades as well!
1 Answer
Steven Parker
231,611 PointsThe difference in the result sets is that the one from the video returns only the teachers who teach 8th grade exclusively. This is what was asked for, so it is correct.
Your query identifies teachers who teach 8th grade students, but it doesn't account for some of them also teaching students in other grades.
The video query uses the SUBJECTS table to get the grade, so it identifies the teachers that teach only 8th grade subjects. It doesn't need to use the STUDENTS table.