How to Select Top 100 rows in Oracle?

前端 未结 5 712
情歌与酒
情歌与酒 2021-01-30 19:58

My requirement is to get each client\'s latest order, and then get top 100 records.

I wrote one query as below to get latest orders for each client. Internal query works

5条回答
  •  再見小時候
    2021-01-30 20:21

    As Moneer Kamal said, you can do that simply:

    SELECT id, client_id FROM order 
    WHERE rownum <= 100
    ORDER BY create_time DESC;
    

    Notice that the ordering is done after getting the 100 row. This might be useful for who does not want ordering.

提交回复
热议问题