Attempting to get total

tjones

Registered User.
Local time
Today, 15:25
Joined
Jan 17, 2012
Messages
199
the fields being used are:
Course Type 1=Core, 2=Elective, 3=Non-degree and 4=Transferred
Course Status completed, withdrew, incomplete
Fields in use by query: UnitCoreTotal, UnitElectiveTotal, and UnitTotal

Unit Core works with:
SELECT Sum(tblCourseTaken.Units) AS TotalCreditsCore, tblCourseTaken.[790ID], tblCourseTaken.CourseTypeID
FROM tblCourseTaken
GROUP BY tblCourseTaken.[790ID], tblCourseTaken.CourseTypeID, tblCourseTaken.CourseStatus
HAVING (((tblCourseTaken.CourseTypeID)=1) AND ((tblCourseTaken.CourseStatus)="Completed"));

Unit Elective works with:
SELECT Sum(tblCourseTaken.Units) AS TotalCreditsEle, tblCourseTaken.[790ID], tblCourseTaken.CourseTypeID
FROM tblCourseTaken
GROUP BY tblCourseTaken.[790ID], tblCourseTaken.CourseTypeID, tblCourseTaken.CourseStatus
HAVING (((tblCourseTaken.CourseTypeID)=2) AND ((tblCourseTaken.CourseStatus)="Completed"));


Unit Total does not work.
I need it to add the coursetype (1 and 2 only) with status of (completed)

SELECT Sum(tblCourseTaken.Units) AS TotalCredits, tblCourseTaken.[790ID], tblCourseTaken.CourseTypeID
FROM tblCourseTaken
GROUP BY tblCourseTaken.[790ID], tblCourseTaken.CourseTypeID, tblCourseTaken.CourseStatus
HAVING (((tblCourseTaken.CourseTypeID)=1 And (tblCourseTaken.CourseTypeID)=2) AND ((tblCourseTaken.CourseStatus)="Completed"));

does not give error, just a blank field.

any help would be appreciated.
this link relates to getting the core and elective working.
http://www.access-programmers.co.uk/forums/showthread.php?t=237074&goto=newpost
 
FIXED:

here is the solution

SELECT Sum(tblCourseTaken.Units) AS TotalCredits, tblCourseTaken.[790ID], tblCourseTaken.CourseStatus
FROM tblCourseTaken
WHERE (((tblCourseTaken.CourseTypeID)=1 Or (tblCourseTaken.CourseTypeID)=2))
GROUP BY tblCourseTaken.[790ID], tblCourseTaken.CourseStatus
HAVING (((tblCourseTaken.CourseStatus)="Completed"));
 

Users who are viewing this thread

Back
Top Bottom