Selecting top n elements of a group in Oracle

前端 未结 5 680
执念已碎
执念已碎 2020-12-10 22:14

I have an Oracle table which has a name,value,time columns.Basically the table is for logging purposes to store what are the changes made to a particular name,what was the p

5条回答
  •  庸人自扰
    2020-12-10 23:05

    select * from (select name, value, 
    time, ROW_NUMBER OVER (PARTITION BY name ORDER BY name) change_no
    from table )
    where change_no <= 100 AND name ="abc"
    ORDER BY TIME
    

    Assuming name remain same, and changes are made to the "value".

提交回复
热议问题