select a.costid,a.add,sum(b.byy) from AA a,AA b where a.costid=substr(b.costid,
0,length(a.costid)) group by a.costid,a.add;
===============================================================
例:
SQL> select * from test4;        ID       COST NAME
---------- ---------- ----------
        13          0 testname
      1301         80 testname
      1302        110 testnameSQL> select a.id,a.name,sum(b.cost) from test4 a,test4 b where a.id=substr(b.id,
0,length(a.id)) group by a.id,a.name;        ID NAME       SUM(B.COST)
---------- ---------- -----------
        13 testname           190
      1301 testname            80
      1302 testname           110