• tommyh (9/19/2011)


    JOIN (SELECT StudentId as StudentNumber, max(RequestNbr) as RequestNb

    FROM Request

    ...

    GROUP BY StudentId) as Latest (StudentId, RequestNbr)

    ON Request.StudentId = Latest.StudentId

    AND Request.RequestNbr = Latest.RequestNbr

    Just to clearify. The whole point was to point out that the bold parts dont match and that SQL instead is using the italic names in the join?

    If above is true then read on... otherwise ignore:

    I got the answer right for all the wrong reasons. I simply didnt see the change in the names. And it took one heck off a time to see the change in the names. When i first read the question i was so sure it would be something odd about the DATE datatype (since one answer had timeportion in it) or something with the MAX in the subquery. So i focused on that but couldnt find anything odd about it. So that left me with only one answer. Which was the right answer.

    PS Im not being sarcastic or anything. I for one learned something... if my assumption is correct. Its just that in this case i feel like the point was drowned in code that wasnt relevant. Though atleast it made me think ALOT 😀

    /T

    yes - pretty much the whole point. And yes - it was a lot of code.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events