• Dird (7/28/2013)


    Do what Jeff said but replace

    PARTITION BY StudentName

    With

    PARTITION BY SubjectName

    I read it as wanting to know the best subject for each student hence the partitioning by StudentName. Partitioning by SubjectName would be to find the best student in each subject. Heh... of course, if we had some sample data and expected results for given sample data, we'd know for sure.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)