Selecting top n elements of a group in Oracle

前端 未结 5 682
执念已碎
执念已碎 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 22:48

    select name, VALUE, TIMESTAMP 
    from (select name, VALUE, TIMESTAMP, rank() over (partition by NAME order by TIMESTAMP DESC) rank 
         from logs) 
    where rank <= 3
    

提交回复
热议问题