Results 1 to 2 of 2

Thread: Sequence No.

  1. #1
    Join Date
    Dec 2003
    Posts
    8

    Unanswered: Sequence No.

    Hi,
    How can I generate a sequence No. using a simple SELECT statement.

    like

    declare @key
    set @key = 1

    SELECT @key, e.name from Employee

    Now I want to display name of the employee and Key value which should get incremented automatically for each employee..
    Is there any way?
    Please help me..

  2. #2
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    select RecordNumber=count(*), e.name from Employee e inner join Employee e1 on e.Key >= e1.Key
    group by e.Key
    order by 1, e.name

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •