How to Select Top 100 rows in Oracle?

前端 未结 5 837
情歌与酒
情歌与酒 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:22

    First 10 customers inserted into db (table customers):

    select * from customers where customer_id <=
    (select  min(customer_id)+10 from customers)
    
    Last 10 customers inserted into db (table customers):
    
    select * from customers where customer_id >=
    (select  max(customer_id)-10 from customers)
    

    Hope this helps....

提交回复
热议问题