Home > Archive > MySQL Server Forum > August 2005 > Having MAX() Query Question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Having MAX() Query Question
nino9stars@yahoo.com

2005-08-23, 8:23 pm

Hello,

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?

Thanks,
Nino Skilj

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com