How do I limit the number of rows returned by an Oracle query after ordering?

前端 未结 17 1543
夕颜
夕颜 2020-11-21 04:56

Is there a way to make an Oracle query behave like it contains a MySQL limit clause?

In MySQL, I can do this:

         


        
17条回答
  •  逝去的感伤
    2020-11-21 05:22

    In oracle

    SELECT val FROM   rownum_order_test ORDER BY val DESC FETCH FIRST 5 ROWS ONLY;
    

    VAL

        10
        10
         9
         9
         8
    

    5 rows selected.

    SQL>

提交回复
热议问题