Having MAX() Query Question

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!


I have a table (PEOPLE) with the following information (Id, Name)

I have another table (CLASSES) with the following information (Id,
Course, Section, Term)

I want to get all the people's names that have are in section 12345 and
that are graduating in term 1000.

So, this is what I came up with:

select PEOPLE.Id, PEOPLE.Name from PEOPLE, CLASSES where
PEOPLE.Id=CLASSES.Id and CLASSES.Section=12345 group by CLASSES.Id
having MAX(CLASSES.Term)=1000 order by PEOPLE.Name;

Unfortunately, this returns an empty set, and I have no idea why?

When I remove the "Section=12345" then I get the result of all the
people that are graduating in 1000.
If I remove the "having MAX(Term)=1000" then I get all the people in
section 1000.

Is there a way to have both?

Nino Skilj

Site Timeline