Generate Sequence Number RRS feed

  • Question

  • User64117442 posted

    Hi All,

    I have data like

    Student ID Document No

    896            1

    896             2

    897             1

    897             2

    I want to generate serial number in the way ,where it assign Serial NO 1 to 896 and 2 to 897.

    I trying to use Rank/Dense_Rank function,but it is not working for me.

    Please help.

    Thanks in Advance

    Monday, October 7, 2013 7:53 AM

All replies

  • User-265225665 posted
    SELECT ROW_NUMBER() OVER (PARTITION BY StudentID ORder by StudentID) AS SeqNo, * FROM Student

    You can use partition by clause with row_number to generate your desired output.

    Monday, October 7, 2013 8:59 AM