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

  • drew.allen (1/11/2012)


    That's true, but this statement from the original poster sounds like the GROUP BY is the correct version.

    kevin_nikolai (1/10/2012)


    If NOT 1st year and same Programme for same Student, then return no results.

    He say 1st year, not 1st consecutive year. Of course, that could simply be a result of poor wording on the part of the OP.

    My point was just that a student might have more than one first year in the same subject (or programme), and the two approaches would produce different results in that case. The GROUP BY/HAVING does also have the drawback of requiring a scan, whereas the NOT EXISTS one could use a seek, of course.