数据库中有一个表,表的属性列有:编号(number),日期(date),品质(quality)等等;其中,编号相同的行日期不一样。我想从表中查询出的结果是:编号为1,2,5,其日期分别为自己最近的3条记录,也就是编号为1的最近的3条记录,编号为2的最近3条记录和编号为5的最近的3条记录,请问用select * from table where number in(1,2,5)这种写法怎么才能实现?请不吝赐教!
解决方案 »
- 帮忙优化oracle的一个SQL 谢谢
- 请教一个关于count的语句
- Oralce 递归查询问题。
- 急,在线等的问题!怎么看ORACLE数据表的索引空间是否已满?
- 急急急~~~!那位大哥能给一个ASP+ORACEL的分页程序呢?将给于最高分的回赠~!在线等侍
- 用VB如何将Oracle中嵌入对象的附件拆离到本地?
- oracle升级后的问题
- pl/sql怎么显示存储过程的内容?
- 存储过程编码找出物料编码为“1”或“5”开头的物料对应的成本对象/产品为“8”或字母开头的成品关系;一共需出具2014-2017年4年对应清单
- 小白刚入公司就收到SQL优化需求
- oracle rac恢复问题 急急!!!!!!!!!1
- 终于生星星了。散200,大家都拿些分,中午节
(select table.*,rank() over(partition by number order by date desc) rk
from table
)
from where rk<=3 and number in(1,2,5)
(select table.*,rank() over(partition by number order by date desc) rk
from table
)
where rk<=3 and number in(1,2,5)
select * from (select row_number() over(partition by number order by date desc ) as rn
,A.* from A where number in (1,2,5))
where rn<=3