Pure-SQL Technique for Auto-Numbering Rows in Result Set

前端 未结 9 1152
误落风尘
误落风尘 2020-12-29 00:20

I\'m looking for a way to sequentially number rows in a result set (not a table). In essence, I\'m starting with a query like the following:

SELECT         


        
9条回答
  •  北荒
    北荒 (楼主)
    2020-12-29 00:56

    In oracle the only database I know what you would want to do is do a sub select on the data

    i.e.

    select rownum, id , blah, blah
    from  (
    select id, name FROM people WHERE name = 'Spiewak'
    )
    

    the basic concept is that the rownum will be evaluated on the result set returned from the inner select.

    I hope this might point you to a solution that you can use.

提交回复
热议问题