spool导出实例:
1. 增加帐户记录:
spool /home/mocsa/subsid_addmoney1.csv
select t.subsid,t.acctid,sum(t.transmoney)
from T_ACCTWATER t
where (trunc(t.TRANSTIME,'dd') between trunc(to_date('20070929','yyyymmdd'),'dd') and trunc(to_date('20071016','yyyymmdd'),'dd') )
and t.TRANSTYPE = 11 and t.REPENISHCHANNEL = '307'
and t.subsid in( select SubsId
from T_ACCTWATER
where (trunc(TRANSTIME,'dd') between trunc(to_date('20070929','yyyymmdd'),'dd')
and trunc(to_date('20071016','yyyymmdd'),'dd') )
and TRANSTYPE = 11 and REPENISHCHANNEL = '307'
group by SubsId
having sum(TRANSMONEY)>10000)
group by t.subsid,t.acctid;
spool off;