473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

MS Access total the results of a query

Hi there,

Very new to MS access and I am having trouble with a certain query.

I have a table that collates order information i.e
Order#, Date, Amount charged, Date paid etc.

Basically I want to create a query that I can input 2 dates and return the total amount paid for all of those dates. I have the date parameter part working so it will return all the records within those 2 dates. I have tried to SUM the amount charged column in there but I can only get it to sum each returned date record. i.e if I do the month of may and 2 orders are on the 12th those are combined.
What I would like to do is return 1 totalled amount for every order in May.

Thank you
Oct 10 '11 #1

✓ answered by NeoPa

In that case don't GROUP BY at all.

Look, you're making this much more difficult than it need be. If you post your SQL we have a much better chance of understanding what you're talking about. I'll include instructions below for how to get that in case you don't yet know.

To extract the SQL from a QueryDef (saved Access query) it is only necessary to view the query in SQL View. This shows the underlying SQL for the QueryDef and is text (See Access QueryDefs Mis-save Subquery SQL for problems with SubQueries). When a QueryDef is open (either in Design View or Datasheet View) it is possible to switch to the SQL View simply by selecting View \ SQL View from the menu.

From here it is simple to Copy & Paste it to wherever you need it.

7 1630
NeoPa
32,556 Expert Mod 16PB
You need to GROUP BY the [Order#] field as well as selecting the [Date] range.
Oct 10 '11 #2
Thank you for the response.

I am only using 2 fields for this query.
Date and Amount
In May I have 4 orders, each for $1000, 2 of these happen to be on the 12th 9the other 2 are 14th and 16th). If I put in the dates 1/5/11 and 31/5/11 i get records back that look like:
(I'm only showing amount not Date)
$2000
$1000
$1000

I'm just looking for a way for that to return 1 record of $4000

Kind regards
Oct 10 '11 #3
NeoPa
32,556 Expert Mod 16PB
In that case don't GROUP BY at all.

Look, you're making this much more difficult than it need be. If you post your SQL we have a much better chance of understanding what you're talking about. I'll include instructions below for how to get that in case you don't yet know.

To extract the SQL from a QueryDef (saved Access query) it is only necessary to view the query in SQL View. This shows the underlying SQL for the QueryDef and is text (See Access QueryDefs Mis-save Subquery SQL for problems with SubQueries). When a QueryDef is open (either in Design View or Datasheet View) it is possible to switch to the SQL View simply by selecting View \ SQL View from the menu.

From here it is simple to Copy & Paste it to wherever you need it.
Oct 10 '11 #4
Expand|Select|Wrap|Line Numbers
  1. SELECT Sum(Invoice.Amount) AS SumOfAmount
  2. FROM Invoice
  3. GROUP BY Invoice.[Date Completed]
  4. HAVING (((Invoice.[Date Completed]) Between [Start Date] And [End Date]));
*
Oct 11 '11 #5
Worked it out thank you, dropped group by and it's working exactly as I want it to
Oct 11 '11 #6
NeoPa
32,556 Expert Mod 16PB
You should probably be looking at a query whose SQL is like :
Expand|Select|Wrap|Line Numbers
  1. SELECT Sum([Amount]) AS [SumOfAmount]
  2. FROM   [Invoice]
  3. WHERE  ([Date Completed] Between [Start Date] And [End Date])
Oct 12 '11 #7
NeoPa
32,556 Expert Mod 16PB
Moobarrymore:
Worked it out thank you, dropped group by and it's working exactly as I want it to
That's good to hear. You also need to change the HAVING clause to a WHERE clause, but if it's working I expect you've worked that out already ;-)
Oct 12 '11 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Paj | last post by:
Hi, I often wish for a really high-level way to access db results, being willing to forego some efficiency. I came up with a class you can use like: cur = db.cursor() cur.execute('select...
1
by: JD | last post by:
I'm using MS Access 97 in an XP environment. I have an append query at the top of a query tree that is behaving strangely. From design view, I can choose view datasheet - and I see one set of...
1
by: Peter Monica | last post by:
I am trying to calculate distance from a point entered by a user usng a function in Access in a query that calls tables in an Oracle database as well as in Access. I am getting the following...
7
by: Peter Bailey | last post by:
I have a query that returns weekly enrollments: Qrygetweeklycountofdosmoduleenrollments Week Commencing Week Ending Total Bookings 02/04/2004 02/04/2004 0 05/04/2004 09/04/2004 0 12/04/2004...
2
by: Chris Hankey | last post by:
I having a strange and annoying problem where Access crashes when the user copies (to the clipboard) the results of a query. The message is not very helpful. It simply says - "Microsoft Access...
4
by: Darryl Kerkeslager | last post by:
I'm trying to construct a simple query (Hah! then why can't I figure it out if it's so simple?) that totals the results where the drug test results are True, negative being treated like any other...
2
by: dollyvishal | last post by:
How to get constraint information for MS Access tables using Query?
0
by: astersathya | last post by:
Date Format in MS Access using a query Hi I want to alter the existing column's format using the alter query. The issue I am facing is I want to set the default date format of an existing...
5
by: bigredseany | last post by:
Hi, I am new to access and I am trying to create some kind of inventory database for my uncles company. Not sure how to explain this, I am trying to just 'link' the total from the bottom of the...
4
by: rdsandy | last post by:
Hi, I have some code below in VBA for Access 2003 which is on a button called "RentalCrosstabPercTtlQtyMonthLoc_Click". This is a crosstab query which brings up rental items down the side, who...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.