开发者

Oracle rownum function

开发者 https://www.devze.com 2023-02-16 20:22 出处:网络
How I can get rownum in orac开发者_C百科le over order by name? i.e In SQL I have a query SELECT

How I can get rownum in orac开发者_C百科le over order by name? i.e In SQL I have a query

  SELECT 
    ROW_NUMBER() OVER(ORDER BY FIRSTNAME) SRL

  FROM   
    [SECURITY].[USERS]

  ORDER BY 
    FIRSTNAME

How will it be in Oracle?


SELECT ROW_NUMBER() OVER(ORDER BY FIRSTNAME)SRL FROM USERS


In Oracle, ROWNUM refers to the current record in the result set (which should be ordered).

SELECT ROWNUM AS SRL
FROM USERS
ORDER BY FIRSTNAME

EDIT: THIS IS WRONG. ROWNUM is assigned BEFORE ordering.

0

精彩评论

暂无评论...
验证码 换一张
取 消