1、先從b中得到每個id最后登陸的紀錄,作為c
2、a左聯接c
2、a左聯接c
解决方案 »
- oracle中如何实现一行数据分为若干组
- PLSQL修改Oracle数据库表的内容问题
- 【急】sql中用case when then else end实现查询
- oracle数据库
- 问下 oracle 的查询语句
- 请问在PROC中使用游标后,是先提交事务,还是先关闭游标?智者见智贴!无分了!
- 如何只比较date字段的月日组合大小,而不考虑年的成分?
- 几组不同写法的SQL语句,大家来看看哪种执行快? 3ks
- 如何修改v$option里的选项值?
- 请问哪里有oledb的驱动?
- 为什么在SQL*Plus中执行查询语句总是提示未选定行呀?
- 代问:中文版的Oracle Universal Installer(就是Oracle安装程序),好像没有地方选择改变字符集?
select A.id, NVL(C.value, 0.0) from A,(select id, value, Date from B bb where Date=(select max(Date) from B where aa.id=B.id group by id)) C where A.id=C.id(+);
create table B(id_ number(8), value_ number(8,2), date_ date);
insert into a values(1);
insert into a values(2);
insert into a values(3);
insert into a values(4);
insert into b values(1,0.1,to_date('2003-01-01','yyyy-mm-dd'));
insert into b values(1,0.2,to_date('2003-01-03','yyyy-mm-dd'));
insert into b values(3,0.5,to_date('2003-02-02','yyyy-mm-dd'));
insert into b values(3,0.1,to_date('2003-05-01','yyyy-mm-dd'));select c.id_, nvl(b.value_,0.0)
from b, (select a.id_, max(b.date_) as date_ from a, b where a.id_=b.id_(+) group by a.id_) c
where b.id_(+)=c.id_ and b.date_(+)=c.date_; ID_ NVL(B.VALUE_,0.0)
---------- -----------------
1 .2
2 0
3 .1
4 0