select fts_voucher_b.interestdate, fts_voucher_b.summary, fts_voucher_b.debitamount 借方, fts_voucher_b.creditamount 贷方, bd_accid.accidcode, bd_accid.accidname, fts_voucher_b.pk_ass from fts_voucher_b, bd_accid where fts_voucher_b.dr = '0' and fts_voucher_b.pk_corp = '1162' and fts_voucher_b.pk_account = bd_accid.pk_accid and bd_accid.accidcode = '011901'--辽宁公司 and fts_voucher_b.creditamount <> 0 and substr(fts_voucher_b.interestdate, 1, 4) = '2013'--年份 and fts_voucher_b.pk_ass not in (select freevalueid from gl_freevalue where valuecode='777777' ) order by fts_voucher_b.interestdate
新课题:统计出分公司的资金归集,取结算凭证的贷方,但是去除777777往来部分
没有想到一个not in就搞定了,777777对每个分公司是不一样的pk_ass,不错
想使用rollup对creditamount最后一行合计,但是没有搞定。
还是使用 sum(fts_voucher_b.creditamount)over( partition by bd_accid.accidcode) 年归集 ,增加一列