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 Predicting the Future

Circular logic of all of these tables "Predicting the Future".

Hi, I keep getting the right answer in a different way.

Can someone please advise if this logic of mine is distorted, and problematic?

See below:

SELECT MIN(CAPACITY) FROM ROOMS JOIN CLASSES ON CLASSES.ROOM_ID = ROOMS.ID JOIN SUBJECTS ON SUBJECTS.ID = CLASSES.SUBJECT_ID WHERE GRADE = "6";

the min Capacity here is still thirty but my way to get there might be a little different. What do you think?

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Jordan young your solution is equally valid in this case. The only problem I could potentially see is if "capacity" was a field on multiple tables. For instance, if the table "Classes" also had a capacity, then you would have to specify which table you want the capacity from. That is not the case here so it understands that you want the minimum capacity from the result of the joins. And there is only one column with that name.

Otherwise, you might have to do something like SELECT MIN(Classes.Capacity) FROM CLASSES so that it would know :smiley:

Hope this helps! :sparkles: