不是很明白你的意思。
是不是求在不同日期的帐目“持平”的帐号?
如果是这样的话,可以试试:select c.accno,c.dat
from
(select accno,dat,sum(amount) sum from a where flag='1' group by accno,dat) c,
(select accno,dat,sum(amount) sum from a where flag='2' group by accno,dat) d
where c.accno=d.accno
and c.dat=d.dat
and c.sum=d.sum;
是不是求在不同日期的帐目“持平”的帐号?
如果是这样的话,可以试试:select c.accno,c.dat
from
(select accno,dat,sum(amount) sum from a where flag='1' group by accno,dat) c,
(select accno,dat,sum(amount) sum from a where flag='2' group by accno,dat) d
where c.accno=d.accno
and c.dat=d.dat
and c.sum=d.sum;
select accno,dat,sum((flag-1.5)*amount)
from a
group by accno,dat
having sum((flag-1.5)*amount)=0;
from table_name
group by accno, dat
having SUM( (to_number(flag)-1.5)*amount))=0