Go Back   CodingForums.com > :: Server side development > MySQL > Other Databases

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-24-2009, 04:07 PM   PM User | #1
cbrashear
New to the CF scene

 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
cbrashear is an unknown quantity at this point
Sql 2008 MAX()Query acroos multiple tables

I am new to sql and have not been able to resolve this issue. I have a query that shows me the information on students we serve. The query pulls all of their classes and the status results as well as contact information. I need to query down to the LAST class taken and the students status. If I take out the following fields I get the correct return but I have to have all the information

dbo.Class.Year,
dbo.ClassResult.ClassResultStatusID,
dbo.Class.SemesterID,
dbo.Location.LocationName,
dbo.Institution.InstName




SELECT MAX(ClassResult.ClassID) AS LASTCLASS,
Person.PersonID,
Person.LastName,
Person.FirstName,
Address.Address1,
Address.City,
Address.State,
Address.Zip,
Class.Year,
ClassResult.ClassResultStatusID,
class.LocationID

FROM Person

INNER JOIN Person_Address ON Person.PersonID = Person_Address.PersonID
INNER JOIN Address ON Person_Address.AddressID = Address.AddressID
INNER JOIN ClassResult ON Person.PersonID = ClassResult.PersonID
INNER JOIN Class ON ClassResult.ClassID = Class.ClassID

GROUP BY Person.PersonID,
Person.LastName,
Person.FirstName,
Address.Address1,
Address.City,
Address.State,
Address.Zip,
Class.Year,
class.LocationID,
ClassResult.ClassResultStatusID
HAVING (ClassResult.ClassResultStatusID NOT IN (4, 8, 10, 12, 13))
ORDER BY Person.LastName, Person.FirstName
cbrashear is offline   Reply With Quote
Reply

Bookmarks

Tags
max, sql2008

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:55 PM.


Advertisement
Log in to turn off these ads.