このディレクトリの索引
http://pc11.2ch.net/test/read.cgi/db/1274791771/248
#  TABLE test 
#  id   | data 
#  ---+------ 
#  100 | AAA 
#   
#  TABLE hoge 
#  id   | value 
#  ---+------ 
#  100 | 10 
#  100 | 20 
#   
#  TABLE 100 
#  id   |val1| val2 
#  ---+---+---- 
#  100 | 20 | 40 
#  100 | 30 | 60 
#   
#  SELECT a.id, test.data, a.cnt + b.cnt + c.cnt 
#  FROM 
#  (SELECT id, SUM( aa.val1 ) cnt FROM (SELECT id, val1 FROM `100`)aa)a, 
#  (SELECT id, SUM( bb.val2 ) cnt FROM (SELECT id, val2 FROM `100`)bb)b, 
#  (SELECT id, SUM( value ) cnt FROM hoge WHERE id = 100)c,test 
#  WHERE a.id = c.id AND test.id = 100 
#   
#  欲しい結果 
#  id    data    a.cnt + b.cnt + c.cnt 
#  ---------------------------- 
#  100  AAA   180 


'欲しい結果 id    data    a.cnt + b.cnt + c.cnt' :-
        test(_id,_data),
        findsum(U,(findsum(_value,hoge(_id,_value),U1),findsum(_val3,('100'(_id,_val1,_val2),_val3 is _val1 + _val2),U2),U is U1 + U2),S).
        write('id    data    a.cnt + b.cnt + c.cnt\n'),
        write_formatted('%t  %t  %t\n',[_id,_data,S]),!.