Row Number in a SELECT statement

  • Is there anyway to produce a row number, similar to an IDENITY (1,1) column in a select statement without creating the identity in the table or using a temp table?

    Something like

     

    SELECT <row number>, * from authors

     

    If there is how do I code <row number>?

  • There is no row number functionality in SQL Server (at least at this time). However you could try using a Subquery to order the data and produce the count of those less than the ordered on field but of course if the items are not unique then you will get duplicate numbers.

  • Could you give me an example of the subquery?

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

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