ACCEPT fund PROMPT 'Enter the FUND (format: #######)'
ACCEPT period PROMPT 'Enter the PERIOD (format: Mon-YY, June-30-YY)'

/*	Date Updated:	10/07/2005
	Created by:		Loren Cook
	Description:	Selects Cash Balances for a given Fund and Period.*/

SELECT
	c.segment1 as "Fund",
	c.segment3 as "BP",
	b.period_name as "Period",
	sum(NVL(b.begin_balance_DR,0) - NVL(b.begin_balance_CR,0) + NVL(b.period_net_DR,0) - NVL(b.period_net_CR,0)) as "Balance"

FROM
	gl.gl_balances b,
	gl.gl_code_combinations c

WHERE
	--Table linking section DO NOT CHANGE.
	b.code_combination_id = c.code_combination_id

	--Enter the desired Period name below (Format: Mmm-YY)
	and  b.period_name = '&period'

	--Enter the desired Funds below
	and c.segment1 = '&fund'

    and c.segment3 != 'T'

	--Enter the desired Natural Account range (11000-11999 = Cash)
	and  c.segment7 between '11000' and '11999'

	--Enter the desired Encumbrance Type below (A=Actuals, B=Budgets, E=Encumbrances)
	and  b.actual_flag = 'A'

	--SET OF BOOKS must equal '1' to only pull SIU information
	and b.ledger_id = '1'

GROUP BY
	c.segment1,
	c.segment3,
	b.period_name

ORDER BY
	"BP"
