Expression Problems in Query

  • Thread starter Stacey Crowhurst
  • Start date
S

Stacey Crowhurst

Hi. I am trying to create a query that adds (Approved Budget) + (Revised
Budget) to get (Current Budget). Here is my SQL:

SELECT [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc], (Sum([Query - Cash Flow_Budgets]![Line
Amount]+[Query - Cash Flow_Revised Budgets]![Line Amount])) AS [Current
Budget]
FROM [Query - Cash Flow_Budgets] INNER JOIN [Query - Cash Flow_Revised
Budgets] ON [Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]
GROUP BY [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc];

When I have the group by selected it shows me no data. When I remove group
by I get the aggregate function error. It seems like such a simple
calculation, I don't know where I went wrong. Help please!!!

Thanks,
Stacey
 
K

KARL DEWEY

Try this --
FROM [Query - Cash Flow_Budgets] LEFT JOIN [Query - Cash Flow_Revised
Budgets] ON [Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]
 
S

Stacey Crowhurst

The query runs and shows the rows I expect, but the current budget column is
empty.
:(

KARL DEWEY said:
Try this --
FROM [Query - Cash Flow_Budgets] LEFT JOIN [Query - Cash Flow_Revised
Budgets] ON [Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]

--
KARL DEWEY
Build a little - Test a little


Stacey Crowhurst said:
Hi. I am trying to create a query that adds (Approved Budget) + (Revised
Budget) to get (Current Budget). Here is my SQL:

SELECT [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc], (Sum([Query - Cash Flow_Budgets]![Line
Amount]+[Query - Cash Flow_Revised Budgets]![Line Amount])) AS [Current
Budget]
FROM [Query - Cash Flow_Budgets] INNER JOIN [Query - Cash Flow_Revised
Budgets] ON [Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]
GROUP BY [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc];

When I have the group by selected it shows me no data. When I remove group
by I get the aggregate function error. It seems like such a simple
calculation, I don't know where I went wrong. Help please!!!

Thanks,
Stacey
 
K

KARL DEWEY

Try it with the Nz function added --
SELECT [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc], (Sum([Query - Cash Flow_Budgets]![Line
Amount]+Nz([Query - Cash Flow_Revised Budgets]![Line Amount]))) AS [Current
Budget]
FROM [Query - Cash Flow_Budgets] LEFT JOIN [Query - Cash Flow_Revised
Budgets] ON[Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]
GROUP BY [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc];

--
KARL DEWEY
Build a little - Test a little


Stacey Crowhurst said:
The query runs and shows the rows I expect, but the current budget column is
empty.
:(

KARL DEWEY said:
Try this --
FROM [Query - Cash Flow_Budgets] LEFT JOIN [Query - Cash Flow_Revised
Budgets] ON [Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]

--
KARL DEWEY
Build a little - Test a little


Stacey Crowhurst said:
Hi. I am trying to create a query that adds (Approved Budget) + (Revised
Budget) to get (Current Budget). Here is my SQL:

SELECT [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc], (Sum([Query - Cash Flow_Budgets]![Line
Amount]+[Query - Cash Flow_Revised Budgets]![Line Amount])) AS [Current
Budget]
FROM [Query - Cash Flow_Budgets] INNER JOIN [Query - Cash Flow_Revised
Budgets] ON [Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]
GROUP BY [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc];

When I have the group by selected it shows me no data. When I remove group
by I get the aggregate function error. It seems like such a simple
calculation, I don't know where I went wrong. Help please!!!

Thanks,
Stacey
 
S

Stacey Crowhurst

Yup! Thanks so much for your help :)

KARL DEWEY said:
Try it with the Nz function added --
SELECT [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc], (Sum([Query - Cash Flow_Budgets]![Line
Amount]+Nz([Query - Cash Flow_Revised Budgets]![Line Amount]))) AS [Current
Budget]
FROM [Query - Cash Flow_Budgets] LEFT JOIN [Query - Cash Flow_Revised
Budgets] ON[Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]
GROUP BY [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc];

--
KARL DEWEY
Build a little - Test a little


Stacey Crowhurst said:
The query runs and shows the rows I expect, but the current budget column is
empty.
:(

KARL DEWEY said:
Try this --
FROM [Query - Cash Flow_Budgets] LEFT JOIN [Query - Cash Flow_Revised
Budgets] ON [Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]

--
KARL DEWEY
Build a little - Test a little


:

Hi. I am trying to create a query that adds (Approved Budget) + (Revised
Budget) to get (Current Budget). Here is my SQL:

SELECT [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc], (Sum([Query - Cash Flow_Budgets]![Line
Amount]+[Query - Cash Flow_Revised Budgets]![Line Amount])) AS [Current
Budget]
FROM [Query - Cash Flow_Budgets] INNER JOIN [Query - Cash Flow_Revised
Budgets] ON [Query - Cash Flow_Budgets].[Budget ID] = [Query - Cash
Flow_Revised Budgets].[Budget ID]
GROUP BY [Query - Cash Flow_Budgets].[CCP No], [Query - Cash
Flow_Budgets].Type, [Query - Cash Flow_Budgets].[Budget Code], [Query - Cash
Flow_Budgets].[Budget Code Desc];

When I have the group by selected it shows me no data. When I remove group
by I get the aggregate function error. It seems like such a simple
calculation, I don't know where I went wrong. Help please!!!

Thanks,
Stacey
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top