• sunitha.yanagandala (9/3/2014)


    select * from

    (

    select ROW_NUMBER()over(Partition by coveragecode) rowno,* from Contract

    )t

    where rowno<=5

    Msg 4112, Level 15, State 1, Line 1

    The function 'row_number' must have an OVER clause with ORDER BY.

    A version of this model which works was posted by Eirikur, second post on this thread.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden