ORA-00979: not a GROUP BY expression

1.select a.actno,b.txamt,max(a.avbal) from lzmr a,lzhtr b where a.actno=b.actno group by a.actno,b.actno

ORA-00979: not a GROUP BY expression


正确写法
select a.actno,sum(b.txamt),max(a.avbal) from lzmr a,lzhtr b where a.actno=b.actno group by a.actno,b.actno



select a.actno,sum(b.txamt),a.avbal from lzmr a,lzhtr b where a.actno=b.actno group by a.actno, avbal


总之,把not a GROUP BY expression的东西放在group by 后面

你可能感兴趣的:(group by)