Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

obtaining a sum in a query

Status
Not open for further replies.

rpmrob

Technical User
Apr 23, 2003
34
0
0
CA
This is probably a very basic question, but here goes: I would like to run a query and then provide the sum of records of a field. Can I do this (query and sum) all in one query, or do I have to run a second query (on the original query) to get the sum.

Woa ...

R
 
Hi,

Kinda hard to generalize, but here goes...
Code:
Select Field1, Sum(Field2)
From MyTable
Group By Field1
:)

Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884

Skip,
 
If you mean like an aggregate sum of some amount by some category/item, yes, you can do this.

Example:

Table: Ledger

Fields: ItemNumber, Qty

Entries in the table are per transaction that takes place with positive quantities being added to what the company has on hand while negative quantities being subtracted from what the company has on hand.

The SELECT Clause of the query would look like:

SELECT ItemNumber, Sum(Qty)
FROM Ledger

Note, the above uses the Aggregate Sum function.

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
When the going gets tough, the tough gets going.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top