A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Simple Question on Addition



 
 
Thread Tools Display Modes
  #1  
Old December 1st, 2009, 04:49 PM posted to microsoft.public.access.queries
GwenH
external usenet poster
 
Posts: 23
Default Simple Question on Addition

I searched the discussion groups for the answer to what seems to be a simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH




  #2  
Old December 1st, 2009, 04:58 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Simple Question on Addition

Gwen

What happens when you run that query?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"GwenH" wrote in message
...
I searched the discussion groups for the answer to what seems to be a
simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in
a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH






  #3  
Old December 1st, 2009, 04:58 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Simple Question on Addition

Gwen

What happens when you run that query?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"GwenH" wrote in message
...
I searched the discussion groups for the answer to what seems to be a
simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in
a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH






  #4  
Old December 1st, 2009, 04:58 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Simple Question on Addition

Gwen

What happens when you run that query?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"GwenH" wrote in message
...
I searched the discussion groups for the answer to what seems to be a
simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in
a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH






  #5  
Old December 1st, 2009, 05:27 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Simple Question on Addition

Use the NZ function (or an IIF statement) to force a value if Credits is Null

SELECT eBayFees_lastMonth.[Item number]
, Sum(eBayFees_lastMonth.Debits) AS SumOfDebits
, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits
, Sum([eBayFees_lastMonth.Debits] + Nz([ebayFees_lastMonth.Credits],0)) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Using an IIF statement:
SELECT eBayFees_lastMonth.[Item number]
, Sum(eBayFees_lastMonth.Debits) AS SumOfDebits
, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits
, Sum(Debits + IIF(Credits is Null,0,Credits)) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

GwenH wrote:
I searched the discussion groups for the answer to what seems to be a simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH




  #6  
Old December 1st, 2009, 05:27 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Simple Question on Addition

Use the NZ function (or an IIF statement) to force a value if Credits is Null

SELECT eBayFees_lastMonth.[Item number]
, Sum(eBayFees_lastMonth.Debits) AS SumOfDebits
, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits
, Sum([eBayFees_lastMonth.Debits] + Nz([ebayFees_lastMonth.Credits],0)) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Using an IIF statement:
SELECT eBayFees_lastMonth.[Item number]
, Sum(eBayFees_lastMonth.Debits) AS SumOfDebits
, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits
, Sum(Debits + IIF(Credits is Null,0,Credits)) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

GwenH wrote:
I searched the discussion groups for the answer to what seems to be a simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH




  #7  
Old December 1st, 2009, 05:27 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Simple Question on Addition

Use the NZ function (or an IIF statement) to force a value if Credits is Null

SELECT eBayFees_lastMonth.[Item number]
, Sum(eBayFees_lastMonth.Debits) AS SumOfDebits
, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits
, Sum([eBayFees_lastMonth.Debits] + Nz([ebayFees_lastMonth.Credits],0)) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Using an IIF statement:
SELECT eBayFees_lastMonth.[Item number]
, Sum(eBayFees_lastMonth.Debits) AS SumOfDebits
, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits
, Sum(Debits + IIF(Credits is Null,0,Credits)) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

GwenH wrote:
I searched the discussion groups for the answer to what seems to be a simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH




  #8  
Old December 1st, 2009, 05:54 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Simple Question on Addition

SELECT eBayFees_lastMonth.[Item number],
Sum(eBayFees_lastMonth.Debits) AS SumOfDebits,
Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits]) +
IsNull(Sum([ebayFees_lastMonth.Credits]),0) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"GwenH" wrote:

I searched the discussion groups for the answer to what seems to be a simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH




  #9  
Old December 1st, 2009, 05:54 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Simple Question on Addition

SELECT eBayFees_lastMonth.[Item number],
Sum(eBayFees_lastMonth.Debits) AS SumOfDebits,
Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits]) +
IsNull(Sum([ebayFees_lastMonth.Credits]),0) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"GwenH" wrote:

I searched the discussion groups for the answer to what seems to be a simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH




  #10  
Old December 1st, 2009, 05:54 PM posted to microsoft.public.access.queries
Jerry Whittle
external usenet poster
 
Posts: 4,732
Default Simple Question on Addition

SELECT eBayFees_lastMonth.[Item number],
Sum(eBayFees_lastMonth.Debits) AS SumOfDebits,
Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits]) +
IsNull(Sum([ebayFees_lastMonth.Credits]),0) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"GwenH" wrote:

I searched the discussion groups for the answer to what seems to be a simple
question, but found nothing. I have a group by query with three columns:

itemNo
Debits
Credits

The query is grouped on the first column, itemNo.

I want to add the Debit column to the credit column and show the result in a
third field, Total. For each record, the Debit column contains currency
amounts. The Credit column contains either negative currency amounts or is
null.

Here is my nonfunctioning SQL. When I run the query, the Total column is
blank for every record.

SELECT eBayFees_lastMonth.[Item number], Sum(eBayFees_lastMonth.Debits) AS
SumOfDebits, Sum(eBayFees_lastMonth.Credits) AS SumOfCredits,
Sum([eBayFees_lastMonth.Debits] + [ebayFees_lastMonth.Credits]) AS Total
FROM eBayFees_lastMonth
GROUP BY eBayFees_lastMonth.[Item number]
ORDER BY eBayFees_lastMonth.[Item number];

Any ideas?

Thanks,
GwenH




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:01 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.