科目余额SQL

select gb.period_year 会计年度,
       gb.period_name 会计期间,
       gcck.concatenated_segments 科目代码,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             
1,
                                             gcck.segment1) 公司,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             
2,
                                             gcck.segment2) 成本中心,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             
3,
                                             gcck.segment3) 会计科目,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             
4,
                                             gcck.segment4) 子科目,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             
5,
                                             gcck.segment5) 产品段,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             
6,
                                             gcck.segment6) 片区,
       gl_flexfields_pkg.get_description_sql(gcck.chart_of_accounts_id,
                                             
7,
                                             gcck.segment7) 备用
       
      ,
       gb.begin_balance_dr 
- gb.begin_balance_cr 期初余额,
       gb.period_net_dr 本期借方发生,
       gb.period_net_cr 本期贷方发生,
       nvl(gb.period_net_dr, 
0- nvl(gb.period_net_cr, 0) 本期净额,
       nvl(gb.begin_balance_dr, 
0+ nvl(gb.period_net_dr, 0-
       nvl(gb.begin_balance_cr, 
0- nvl(gb.period_net_cr, 0) 期末余额
  
from gl.gl_balances           gb,
       gl_code_combinations_kfv gcck
 
where gb.code_combination_id = gcck.code_combination_id
   
and gb.currency_code = 'CNY'
   
and gcck.summary_flag = 'N'
   
and gb.actual_flag = 'A'

 

   AND gb.period_name = '2010-11'
   AND gcck.concatenated_segments like '02.021200.6501.%.0000.0000.000' 


posted @ 2010-12-31 11:12  郭振斌  阅读(2150)  评论(0编辑  收藏  举报