number grouped sets ( SQL 2005)

  • Hi,

    I have a table as following

    SSN Amount

    1 101

    1 210

    1 120

    2 220

    2 150

    2 300

    Is there a way that I can have them grouped by SSN and number them starting from 1 to 3.

    The number of records in a group are fixed. (like in above case, it is 3).

    The following table is required

    row_num SSN Amount

    1 1 101

    2 1 210

    3 1 120

    1 2 220

    2 2 150

    3 2 300

  • SELECT ROW_NUMBER() OVER PARTITON BY SSN ORDER BY Amount) AS row_num,

    SSN, Amount

    FROM Table1


    N 56°04'39.16"
    E 12°55'05.25"

  • Thanks SwePeso!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply