Home Forums SQL Server 2008 T-SQL (SS2K8) if 2nd year and same Programme for same Student, then return no results RE: if 2nd year and same Programme for same Student, then return no results
Paul White
SSC Guru
Points: 150468
More actions
January 10, 2012 at 5:33 pm
#1431519
Isn't it as simple as:
SELECT
*
FROM #Students AS s
WHERE
s.[Year] = 2009
AND NOT EXISTS
(
SELECT *
FROM #Students AS s2
s2.StudentID = s2.StudentID
AND s2.Programme = s.Programme
AND s2.[Year] = s.[Year] - 1
);
Paul WhiteAll articles available on SQL.kiwi@SQL_Kiwi