日期:2014-05-18 浏览次数:20818 次
drop table t; create table t (ID varchar2(10),batch varchar2(10),round number(10),edate date); insert into t values('a','1',1,sysdate); insert into t values('a','1',2,sysdate); insert into t values('a','2',3,sysdate); insert into t values('a','2',4,sysdate); insert into t values('a','3',4,sysdate); insert into t values('a','4',4,sysdate); insert into t values('b','1',4,sysdate); insert into t values('b','2',4,sysdate); select id,sum(round) from t a where (select count(*) from t b where b.round>a.round and b.id=a.id and b.batch=a.batch)=0 group by id;