Solved

Budget and Cost Report

Posted on 2012-03-19
1
282 Views
Last Modified: 2012-03-25
I am currently working on the above report.  The monthly budgets are contained in one table, the costs in another.  If work from the budgets table to costs I can see all costs against a cost code that has a budget, but if costs are incurred against a cost code that doesn't have a budget this will be missed.  I could work the other way from costs to budgets but the report wouldn't show costs codes that had a budget but where no costs had been incurred.

Please can someone advise on the best approach?
0
Comment
Question by:Damozz
1 Comment
 
LVL 42

Accepted Solution

by:
dqmq earned 500 total points
ID: 37739960
Use an outer join to get all costs with their budgets (or lack thereof)

Select...
from Costs c left join budgets b on c.costcode = b.costcode

go the other way to get all budgets with their costs (or lack thereof)
Select...
from Costs c right join budgets b on c.costcode = b.costcode

Most reports are best developed with one of the above forms.  To see it both ways, probably best to use two reports or two sub-reports.


You can also use full outer join  to get all budgets and all costs at one time, but it gets a little tricky developing a meaningful report when sometimes the budgets are missing and sometimes the costs are missing.

Select...
from Costs c full outer join budgets b on c.costcode = b.costcode
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now