开发者

Oracle rownum function

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜