[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to subtotal a field in a Access query which is being counted?

Posted on 2006-11-06
2
Medium Priority
?
229 Views
Last Modified: 2006-11-18
In the acess query builder, I set one of the fields to count function, so I would get the total number of alarms each day for each pump.  My current result from the query look like the following:

Equipment -- Date -- Number of Alarms
=========================
PUMP10 -- 10/24/06 -- 10
PUMP10 -- 10/25/06 -- 5
PUMP10 -- 10/22/06 -- 5
PUMP2 -- 10/24/06 -- 10
PUMP2 -- 10/20/06 -- 10
PUMP2 -- 10/21/06 -- 10
PUMP24 -- 10/19/06 -- 12
PUMP24 -- 10/12/06 -- 10

I would like to have a subtotal show up for each pump.  PUMP10 = 20 total, PUMP2 = 30 total, etc.  Then I would like to sort them so the pump with the largest combined total of alarms shows up first in the list (sort descending).  The report will show the pump with the largest number of alarms first with a breakdown of how many alarms occurred for that pump and on what day.
I am not sure if I can do this in a query or if I need to do this in a report form.  I am not sure if I need a second query so that it will sort by total alarms for each pump.  

Your help is very much appreciated.

0
Comment
Question by:r_may
2 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 2000 total points
ID: 17885376
Something like this perhaps , note I dont know your query so I dont know how u do your count

SELECT Equipment, [Date], YourCountField
FROM mytable
GROUP BY Equipment, [Date]
UNION ALL
SELECT Equipment, 'Total' DSUM("*","mytable","Equipment='" & A.Equipment & "'") AS Total
FROM Mytable as A
ORDER BY 1,2
0
 

Author Comment

by:r_may
ID: 17902615
Thanks. I will give this a try.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

872 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