当前位置:Gxlcms > 数据库问题 > oracle获取排序第一的数据

oracle获取排序第一的数据

时间:2021-07-01 10:21:17 帮助过:2人阅读

a.* FROM ( select * from ( select t.*,row_number() over(partition by t.id order by t.createtime desc) rn from table t ) c where rn = 1) a where a.id= 001;--加上where条件是查询一条,不加是查询多条

 

二:如果是获取时间最新一条数据

SELECT * FROM table  WHERE  (id,createtime)  IN (SELECT id,MAX(createtime)  createtime  FROM  table  GROUP  BY  id);--获取时间最新的多条数据

SELECT * FROM table where a.id=018  and createtime=(SELECT MAX(createtime) FROM table where a.id=018);--获取一条时间最新的数据

 

oracle获取排序第一的数据

标签:sele   create   group   div   and   weight   HERE   over   字段排序   

人气教程排行