这是查询实际发生额的一个函数看对你有没有帮助 SELECT sum(a.LINE_ENTERED_DR_NUM)
into money
FROM apps.GL_JE_JOURNAL_LINES_V a
WHERE a.SET_OF_BOOKS_ID = 1
AND a.BATCH_STATUS = 'P'
AND (a.CURRENCY_CODE != 'STAT')
AND (a.ACTUAL_FLAG = 'A')
AND trim(nvl(a.PERIOD_NAME, 'XXX')) =
trim(to_char(to_date(p_y || '-' || p_m, 'YYYY-MM'),
'MON-YY',
'NLS_DATE_LANGUAGE=American'))
AND (a.LINE_CODE_COMBINATION_ID in
(SELECT CODE_COMBINATION_ID ccid
FROM apps.gl_code_combinations
WHERE CHART_OF_ACCOUNTS_ID = 50248
AND segment2 = p_department_id
and segment3 = p_account_id));