I have a query that I'm trying to return all Projects and the budget for any of those projects that exist. If a budget doesn't exist, I want to show 0s. For some reason, I can't get rid of #Error for these fields when the left join doesn't return something. Below is my query with all of the different attempts of handling this issue:
I've attached a screen shot of the data the query is returning. Any ideas?
[imgnothumb]http://bytes.com/attachments/attachment/6655d1350132937/left_join_error s.jpg[/imgnothumb]
Thanks
Joe
Code:
SELECT Project.UCMG_CD,
Project.SPRF,
Project.PROJECT_NAME,
iif(isnull(BudgetImport_IDSplit.Current_Prompt_Estimate),0,BudgetImport_IDSplit.Current_Prompt_Estimate) AS Current_Prompt_Estimate,
nz(BudgetImport_IDSplit.Hist_Spend,0) AS Hist_Spend,
BudgetImport_IDSplit.Current_Prompt_Estimate-BudgetImport_IDSplit.Hist_Spend AS CY_Approve_UHGIT_Budget,
iif(iserror(BudgetImport_IDSplit.CY_UHGIT_Spend),0,BudgetImport_IDSplit.CY_UHGIT_Spend) AS CY_UHGIT_Spend,
BudgetImport_IDSplit.CY_Remain_Spend AS CY_Remain_Spend,
BudgetImport_IDSplit.CY_UHGIT_Spend+BudgetImport_IDSplit.CY_Remain_Spend AS CY_Total_Proj_Spend
FROM Project
LEFT JOIN BudgetImport_IDSplit
ON Project.SPRF = BudgetImport_IDSplit.SPRF;
[imgnothumb]http://bytes.com/attachments/attachment/6655d1350132937/left_join_error s.jpg[/imgnothumb]
Thanks
Joe
Comment