T-sql 2012 most current year

       In the following t-sql 2012, I want to select records from the AMilestone table when
           the schoolyear is the most current year from the  ASemester table.   
             select *
	from ASemester ASemester
	join AMilestone AMilestone 
	on AMilestone.SCHOOLYEAR  = ASemester.SCHOOLYEAR
	where ASemester.SCHOOLYEAR = ASemester.max(SCHOOLYEAR)

The sql listed above does not work. Thus would you show me the t-sql on how to solve my problem?

SELECT *
FROM AMilestone M
WHERE M.SCHOOLYEAR = (SELECT MAX(S.SCHOOLYEAR) FROM ASemester S);
1 Like