Solved

Budget and Cost Report

Posted on 2012-03-19
1
285 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

726 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