How to generate auto ID in my query result? Thanks.

  • Hello,

    I have a query below:

    select UserLogon, ROW_NUMBER() OVER(Order By createdon desc) as ID, Description, IP, CreatedOn from eventlog

    Group by UserLogon, Description, IP, CreatedOn

    order by createdon desc

    What I really want to do is to return auto number, but I want the auto number starts from 1 for each new group (in this case UserLogon)

    Can any one tell me how to do this? Thanks lots.

  • OVER (PARTITION BY UserLogon ORDER BY createdon DESC)

  • Thank you my friend

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

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