按公司、年、期间id、当前期间id、科目、币别、期初余额、借贷金额、期末余额,查询科目余额表情况
select
co.fnumber as EntityCode
,co.fname_l2 as EntityName
,pd.fperiodyear as Year
,bal.FPERIODID as PrdId
,( select ctrl.fcurrentperiodid from T_BD_SystemStatusCtrol ctrl where ctrl.fsystemstatusid =‘e45c1988-00fd-1000-e000-33d8c0a8100d02A5514C’ and ctrl.fcompanyid= bal.forgunitid)as CrtPrdId ----取当前总账会计期间
,ac.fnumber as AccountCode
,ac.fname_l2 as AccountName
,cur.fname_l2 as cur
, bal.FBeginBalanceLocal as BeginBalanceLocal
,bal.FDebitLocal as DebitLocal
,bal.FCreditLocal as CreditLocal
, bal.FEndBalanceLocal as EndBalanceLocal
from T_GL_AccountBalance bal
left outer join t_org_company co on bal.forgunitid=co.fid
left outer join T_BD_AccountView ac on bal.faccountid=ac.fid
left outer join t_bd_period pd on bal.fperiodid=pd.fid
left outer join t_bd_currency cur on bal.fcurrencyid=cur.fid
where cur.fnumber not in (‘GLC’,‘GRC’) and bal.FBALTYPE=1 and ac.flevel=1
order by EntityCode,Year,AccountCode