select * from GL_Journal;
select * from AA_Account;
--标准化凭证表
drop table 用友凭证表;
select * from 用友凭证表;
select
idaccount as 科目ID,
year as 年份,
currentperiod as 月份,
docno as 凭证号,
rowno as 分录号,
summary as 摘要,
--case direction when 652 then '借' else '贷' end 借贷方向,
--round(periodBeginAmountDr,2) as 期初本币借方金额,
--round(periodBeginAmountCr,2) as 期初本币贷方金额,
cast(isnull(amountDr,0) as money) 借方金额,
cast(isnull(amountCr,0) as money) 贷方金额
into 用友凭证表
from GL_Journal
where currentperiod <> 0
order by 2,3,4;
--连接标准化科目表_含上级
select *
from 用友凭证表_含科目全称;
select a.年份,a.月份,a.凭证号,a.分录号,
b.编号,
b.科目全称,
a.摘要,a.借方金额,a.贷方金额
--into 用友凭证表_含科目全称
from 用友凭证表 a, 用友科目表_含上级全称 b
where a.科目ID = b.科目ID and a.年份 = b.会计年
order by 1,2,3,4;
--科目全称表生成语句详见《用友T+财务软件数据库——SQL生成含上级科目的标准化科目表》