I have a union query for two unrelated tables:
I need to find the number of unique StudentIDs per AcademicYr. Some students are in both a pair and a class in a given year, but I need to count each student only once per year. I can't just do a unique StudentID, though, because some students are enrolled in multiple years.
Can't quite figure out how to get the results I want.
Thanks!
Code:
SELECT PairID, "Pair" AS [Relationship],StudentID,AcademicYr
FROM tblPairAssignment
GROUP BY PairID, StudentID, AcademicYr
ORDER BY StudentID
UNION SELECT AssignmentID, "Class" AS [Relationship], StudentID, AcademicYr
FROM tblClassAssignment
GROUP BY AssignmentID, StudentID, AcademicYr
ORDER BY StudentID;
I need to find the number of unique StudentIDs per AcademicYr. Some students are in both a pair and a class in a given year, but I need to count each student only once per year. I can't just do a unique StudentID, though, because some students are enrolled in multiple years.
Can't quite figure out how to get the results I want.
Thanks!