SQL Row_Number() function in Where Clause without ORDER BY?

前端 未结 5 1137
北海茫月
北海茫月 2020-12-08 06:45

I found a bunch of questions on this topic with nice solutions but none of them actually deal with what to do if the data is not to be ordered in one specific way. For insta

5条回答
  •  青春惊慌失措
    2020-12-08 07:12

    Just in case it is useful to someone else. I just figured it out from elsewhere:

    WITH MyCte AS 
    (
        select   employee_id,
                 RowNum = row_number() OVER (ORDER BY (SELECT 0))
        from     V_EMPLOYEE 
        ORDER BY Employee_ID
    )
    SELECT  employee_id
    FROM    MyCte
    WHERE   RowNum > 0
    

提交回复
热议问题