SELECT GP.PERIOD_NAME
,GP.PERIOD_YEAR
,GP.PERIOD_NUM
,GB.CODE_COMBINATION_ID
,GB.CURRENCY_CODE
,GC.SEGMENT1
,MEW_GET_ACCOUNT_DESC_FNC(GC.CHART_OF_ACCOUNTS_ID
,GC.CODE_COMBINATION_ID
,GC.SEGMENT1
,1) SEGMENT1_DESC
,GC.SEGMENT2
,MEW_GET_ACCOUNT_DESC_FNC(GC.CHART_OF_ACCOUNTS_ID
,GC.CODE_COMBINATION_ID
,GC.SEGMENT2
,2) SEGMENT2_DESC
,GC.SEGMENT3
,MEW_GET_ACCOUNT_DESC_FNC(GC.CHART_OF_ACCOUNTS_ID
,GC.CODE_COMBINATION_ID
,GC.SEGMENT3
,3) SEGMENT3_DESC
,GC.SEGMENT4
,MEW_GET_ACCOUNT_DESC_FNC(GC.CHART_OF_ACCOUNTS_ID
,GC.CODE_COMBINATION_ID
,GC.SEGMENT4
,4) SEGMENT4_DESC
,GC.SEGMENT5
,MEW_GET_ACCOUNT_DESC_FNC(GC.CHART_OF_ACCOUNTS_ID
,GC.CODE_COMBINATION_ID
,GC.SEGMENT5
,5) SEGMENT5_DESC
,GC.SEGMENT6
,MEW_GET_ACCOUNT_DESC_FNC(GC.CHART_OF_ACCOUNTS_ID
,GC.CODE_COMBINATION_ID
,GC.SEGMENT6
,6) SEGMENT6_DESC
,GC.SEGMENT7
,MEW_GET_ACCOUNT_DESC_FNC(GC.CHART_OF_ACCOUNTS_ID
,GC.CODE_COMBINATION_ID
,GC.SEGMENT7
,7) SEGMENT7_DESC
,GB.BEGIN_BALANCE_DR - GB.BEGIN_BALANCE_CR BEGIN_BALANCE --期初余额 原币
,DECODE(GB.CURRENCY_CODE
,'CNY'
,GB.BEGIN_BALANCE_DR - GB.BEGIN_BALANCE_CR
,GB.BEGIN_BALANCE_DR_BEQ - GB.BEGIN_BALANCE_CR_BEQ) BEGIN_BALANCE_BEQ --期初余额 本币
,GB.PERIOD_NET_DR --本期借方发生额 原币
,GB.PERIOD_NET_DR_BEQ --本期借方发生额 本币
,GB.PERIOD_NET_CR --本期贷方发生额 原币
,GB.PERIOD_NET_CR_BEQ --本期贷方发生额 本币
,(GB.BEGIN_BALANCE_DR - GB.BEGIN_BALANCE_CR + GB.PERIOD_NET_DR -
GB.PERIOD_NET_CR) YTD_BALANCE --期末余额 原币
,(GB.BEGIN_BALANCE_DR_BEQ - GB.BEGIN_BALANCE_CR_BEQ +
GB.PERIOD_NET_DR_BEQ - GB.PERIOD_NET_CR_BEQ) YTD_BALANCE_BEQ --期末余额 本币
FROM GL_BALANCES GB
,GL_CODE_COMBINATIONS_KFV GC
,GL_PERIOD_STATUSES_V GP
WHERE GB.ACTUAL_FLAG = 'A'
AND GB.CODE_COMBINATION_ID = GC.CODE_COMBINATION_ID
AND GB.PERIOD_NAME = GP.PERIOD_NAME
AND GB.SET_OF_BOOKS_ID = GP.SET_OF_BOOKS_ID
AND GP.APPLICATION_ID = 101
AND GP.SET_OF_BOOKS_ID = 143
AND GP.PERIOD_YEAR || '-' || LPAD(GP.PERIOD_NUM
,2
,'0') >= '2012-01'
AND GP.PERIOD_YEAR || '-' || LPAD(GP.PERIOD_NUM
,2
,'0') <= '2012-03'