I have 2 tables (table-A & table-B). They are defined as such:
TABLE-A
DEPARTMENT
ACCOUNT
TABLE-B
DEPARTMENT
ACCOUNT
SPEND
BUDGET
TABLE-A is my driver for my query as it has all the departments and accounts, whereas TABLE-B only has records for the departments and accounts that have either a spend or a budget amount associated with it.
I need to report on all department / accounts regardless if there is a spend or budget amount, thus I know I need to do an outer join such as:
select a.department, a.account, b.spend, b.budget
from table-a a LEFT OUTER JOIN table-b b on
a.department = b.department and
a.account = b.account
my problem is HOW DO I INSERT VALUES of zero FOR SPEND & BUDGET when there isn't a record in table-b ???
many many thanks!
TABLE-A
DEPARTMENT
ACCOUNT
TABLE-B
DEPARTMENT
ACCOUNT
SPEND
BUDGET
TABLE-A is my driver for my query as it has all the departments and accounts, whereas TABLE-B only has records for the departments and accounts that have either a spend or a budget amount associated with it.
I need to report on all department / accounts regardless if there is a spend or budget amount, thus I know I need to do an outer join such as:
select a.department, a.account, b.spend, b.budget
from table-a a LEFT OUTER JOIN table-b b on
a.department = b.department and
a.account = b.account
my problem is HOW DO I INSERT VALUES of zero FOR SPEND & BUDGET when there isn't a record in table-b ???
many many thanks!