I am working on budget report which is supposed to display posted budget amounts and also posted actuals for selected accounts (trough account category) and selected periods. So far everything works fine except there are some accounts that have no postings in either table (budget and actual) and those accounts don't get displayed (which is expected). But, user want to be able to see these acounts as well (with zero budget and zero for actual for selected period). Any idea how to achive this? Here is my SQL statement entered in command:
select
b.account_cat_id,
b.description,
a.entity_id,
a.budget_id,
a.account_id,
a.debit_amount BUDGET,
a.posting_date,
0 ACTUAL
from
ledger_account_budget a,
ledger_account b,
ledger_account_category c
where
a.entity_id = 'CORP' and
a.posting_date >={?BeginDate} and
a.posting_date <={?EndDate} and
a.currency_id='CDN' and
b.entity_id = a.entity_id and
b.account_id = a.account_id and
c.id = a.account_cat_id and
c.account_class in( 'EXP', 'ASSET')
union all
select
b.account_cat_id,
b.description,
a.entity_id,
a.budget_id,
a.account_id,
a.credit_amount BUDGET,
a.posting_date,
0 ACTUAL
from
ledger_account_budget a,
ledger_account b,
ledger_account_category c
where
a.entity_id = 'CORP' and
a.posting_date >={?BeginDate} and
a.posting_date<={?EndDate} and
a.currency_id='CDN' and
b.entity_id = a.entity_id and
b.account_id = a.account_id and
c.id = a.account_cat_id and
c.account_class not in( 'EXP', 'ASSET')
union all
select
b.account_cat_id,
b.description,
a.entity_id,
' ',
a.account_id,
0,
a.posting_date,
a.debit_amount - a.credit_amount ACTUAL
from
ledger_account_balance a,
ledger_account b
where
a.entity_id = 'CORP' and
a.posting_date> ={?BeginDate} and
a.posting_date< ={?EndDate} and
a.currency_id='CDN' and
b.entity_id = a.entity_id and
b.account_id = a.account_id
Edited by BrianBischof - 12 Aug 2008 at 6:46am