SQL Row_Number() function in Where Clause

后端 未结 10 1510
野性不改
野性不改 2020-12-02 16:11

I found one question answered with the Row_Number() function in the where clause. When I tried one query, I was getting the following error:

10条回答
  •  遥遥无期
    2020-12-02 17:04

    SELECT  employee_id
    FROM    (
            SELECT  employee_id, ROW_NUMBER() OVER (ORDER BY employee_id) AS rn
            FROM    V_EMPLOYEE
            ) q
    WHERE   rn > 0
    ORDER BY
            Employee_ID
    

    Note that this filter is redundant: ROW_NUMBER() starts from 1 and is always greater than 0.

提交回复
热议问题