这个很麻烦的,最好是写个存储过程,把资产负债表的数据都取出来再展现。用友的资产负债表数据一般从科目总账表:GL_accsum 表中获取,按照ufo中的公式,取相应科目的值。
你找几个项目,把对应的ufo公式发给我,我给写一两个看数据对不对,
把下面的全部复制到你的sql查询软件里面看一下数据对不对,其中数据库名 ‘UFDATA_088_2018’要改成你自己U8的数据库名。
-- 货币资金:QM(\"1001\",月,,,年,,)+QM(\"1002\",月,,,年,,)+QM(\"1012\",月,,,年,,)
-- 货币资金 2022年2月份数据
select sum(c1001_jie-c1001_dai+c1002_jie-c1002_dai+c1012_jie-c1012_dai) sm from ( select iyperiod,
case when (ccode ='1001' and cendd_c='借') then ISNULL(me,0) else 0 end AS c1001_jie,
case when (ccode ='1001' and cendd_c='贷') then ISNULL(me,0) else 0 end AS c1001_dai,
case when (ccode ='1002' and cendd_c='借') then ISNULL(me,0) else 0 end AS c1002_jie,
case when (ccode ='1002' and cendd_c='贷') then ISNULL(me,0) else 0 end AS c1002_dai,
case when (ccode ='1012' and cendd_c='借') then ISNULL(me,0) else 0 end AS c1012_jie,
case when (ccode ='1012' and cendd_c='贷') then ISNULL(me,0) else 0 end AS c1012_dai
from UFDATA_088_2018.dbo.gl_accsum where iyperiod='202202'
) aa group by aa.iyperiod
-- 短期投资:QM(\"1101\",月,,,年,,)
-- 短期投资 2022年2月份数据
select sum(c1101_jie-c1101_dai) sm from ( select iyperiod,
case when (ccode ='1101' and cendd_c='借') then ISNULL(me,0) else 0 end AS c1101_jie,
case when (ccode ='1101' and cendd_c='贷') then ISNULL(me,0) else 0 end AS c1101_dai from UFDATA_088_2018.dbo.gl_accsum where iyperiod='202202'
) aa group by aa.iyperiod
--应收账款:QM(\"1122\",月,\"借\",,,,,,,,)+QM(\"2203\",月,\"借\",,,,,,,,)
-- 应收账款 2022年2月份数据
select sum(c1122_jie-c1122_dai+c2203_jie-c2203_dai) sm from ( select iyperiod,
case when (ccode ='1122' and cendd_c='借') then ISNULL(me,0) else 0 end AS c1122_jie,
case when (ccode ='1122' and cendd_c='贷') then ISNULL(me,0) else 0 end AS c1122_dai,
case when (ccode ='2203' and cendd_c='借') then ISNULL(me,0) else 0 end AS c2203_jie,
case when (ccode ='2203' and cendd_c='贷') then ISNULL(me,0) else 0 end AS c2203_dai
from UFDATA_088_2018.dbo.gl_accsum where iyperiod='202202'
) aa group by aa.iyperiod
------- 或者直接用下面的语句----------
select sum(case cendd_c when '借' then me when '贷' then (0 - me) else 0 end) sm from UFDATA_088_2018.dbo.gl_accsum --借减贷
where iyperiod='202202' and ccode in ('1001','1002','1012')