Hi. I am very new to programming and sql. Right now I am creating a gradebook to hold student's courses, grades, and teachers.
Students may be able to retake a subject and thereby receive a different grade than first obtained. I would like to create a query that shows only the most recent grade a student received for any subject.
I have the following query to do such for Social Studies:
SELECT tbl_SocialStudies.ID, tbl_SocialStudies.Name, tbl_SocialStudies.Score, tbl_SocialStudies.Date
FROM tbl_SocialStudies RIGHT JOIN [SELECT Name, Max(Date) AS Latest FROM tbl_SocialStudies GROUP BY Name]. AS Recent ON (tbl_SocialStudies.Name=Recent.Name) AND (tbl_SocialStudies.Date=Recent.Latest);
Which runs fine. However, for some reason this keeps switching to:
SELECT tbl_SocialStudies.ID, tbl_SocialStudies.Name, tbl_SocialStudies.Score, tbl_SocialStudies.Date
FROM tbl_SocialStudies RIGHT JOIN [SELECT Name, Max(Date) AS Latest FROM tbl_SocialStudies GROUP BY Name; ] AS Recent ON (tbl_SocialStudies.Name=Recent.Name) AND (tbl_SocialStudies.Date=Recent.Latest);
In the GROUP BY clause Name]. keeps jumping to Name;] after the query is saved. I have to keep fixing it everytime I want to see the results.
Is there a particular reason why this is happening.