Increment one for each row in given group...

  • I have a query where I need to increment one for each row in given group...

    I have:

    ID, Name, DateOfServ

    1401593, Sheri, 09/22/2010

    1401593, Sheri, 09/23/2010

    1401593, Sheri, 09/26/2010

    1401594, Tom, 09/21/2010

    1401595, Joe, 09/24/2010

    1401595, Joe, 09/26/2010

    1401596, Timothy, 09/19/2010

    1401596, Timothy, 09/20/2010

    1401597, Bob, 09/22/2010

    What I am looking to accomplish is:

    ID, Name, DateOfServ, LineNum

    1401593, Sheri, 09/22/2010,1

    1401593, Sheri, 09/23/2010,2

    1401593, Sheri, 09/26/2010,3

    1401594, Tom, 09/21/2010,1

    1401595, Joe, 09/24/2010,1

    1401595, Joe, 09/26/2010,2

    1401596, Timothy, 09/19/2010,1

    1401596, Timothy, 09/20/2010,2

    1401597, Bob, 09/22/2010,1

    Any suggestions or code on how I could complete this would be greatly appreciated..Thanks!

  • ROW_NUMBER() OVER(PARTITION BY Group, Date ORDER BY Whatever)

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

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