SQLTeam.com | Weblogs | Forums

T-sql 2012 most current year

#1
       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?

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