473,671 Members | 2,305 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sum() randomly doubles in query

I am running into a really odd problem with Access and looking for some
insight as to what could be causing my issue. Basically this SQL
creates a listing of Total Sales (Sum(InvLine.Re tail)) by Category
(InvLine.Cat) which seems strait forward. But today I run the report
and a category is doubled, so I went through the basic steps of
verifying the data's intergrety wih other categories etc and nothing is
diffent about the line but instead of 4.75 its 9.50. Also even tried
changing to InvLine.Price and it doubled that as well?!?!

The problem is a single line in Table InvLine which is the only line
for this category for the report that I ran.

LId IId InvDayId IType D TS TE Unit Description Contact Quantity Retail Price TGId Total UGId Exported Cat RevAccountId
65576 10999 40088 2 3/21/2006 0 0 0 Umpqua 300
#4 1 $4.75 $4.75 3 $5.13 1 $0.00 04 Fly Tying 3

Here is my SQL

SELECT InvLine.Cat, Sum(InvLine.Ret ail) AS TotalCat
FROM Payments INNER JOIN ((InvLine INNER JOIN Invoice ON InvLine.IId =
Invoice.IId) INNER JOIN PaySplit ON Invoice.IId = PaySplit.IId) ON
Payments.PAYId = PaySplit.PayId
WHERE (((Invoice.Tota l)=[Invoice].[Paid]) AND ((Payments.PayD ate)
Between #3/20/2006# And #3/22/2006#))
GROUP BY InvLine.Cat
ORDER BY InvLine.Cat;

Any Ideas?

Mar 21 '06 #1
2 4593
sb*********@gma il.com wrote:
I am running into a really odd problem with Access and looking for some
insight as to what could be causing my issue. Basically this SQL
creates a listing of Total Sales (Sum(InvLine.Re tail)) by Category
(InvLine.Cat) which seems strait forward. But today I run the report
and a category is doubled, so I went through the basic steps of
verifying the data's intergrety wih other categories etc and nothing is
diffent about the line but instead of 4.75 its 9.50. Also even tried
changing to InvLine.Price and it doubled that as well?!?!

The problem is a single line in Table InvLine which is the only line
for this category for the report that I ran.

LId IId InvDayId IType D TS TE Unit Description Contact Quantity Retail Price TGId Total UGId Exported Cat RevAccountId
65576 10999 40088 2 3/21/2006 0 0 0 Umpqua 300
#4 1 $4.75 $4.75 3 $5.13 1 $0.00 04 Fly Tying 3

Here is my SQL

SELECT InvLine.Cat, Sum(InvLine.Ret ail) AS TotalCat
FROM Payments INNER JOIN ((InvLine INNER JOIN Invoice ON InvLine.IId =
Invoice.IId) INNER JOIN PaySplit ON Invoice.IId = PaySplit.IId) ON
Payments.PAYId = PaySplit.PayId
WHERE (((Invoice.Tota l)=[Invoice].[Paid]) AND ((Payments.PayD ate)
Between #3/20/2006# And #3/22/2006#))
GROUP BY InvLine.Cat
ORDER BY InvLine.Cat;

Any Ideas?

Using a dumb example, let's say I have an Order and 2 customers
associated with the order. If I did a sum on the order amount
(contained in the order table) and I was linked also to the
CustomerOrder table, I woulld get a doubling value.

Any easy way to view this is to make a copy of your query. Remove the
Totals query so it becomes a simple SQL select. Now filter on the
category that it is messing up on. I think you'll find that somehow you
have 2 records of something that makes it double.
Mar 22 '06 #2
Son of a gun your right I was just thinking about this the wrong way
perfect thank you!! Just to tell you what happened, the cash
transactions have 2 lines total cash paid and change given that was it.

Mar 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1883
by: Giloosh | last post by:
Hello i have been trying to figure out this problem for a very long time now, and thought maybe its worth asking for some help. I want to figure out if there is a way to create a field in a select query that acts as a "COUNT" for the fields in the query. No matter what order the rest of the fields will be it will always remain in numerical order from 0+. Field one will be 1, field 2 will be 2, field 3 will be 3...etc. The reason i...
3
2200
by: Joost | last post by:
I have a form based on a totals query, with one of the fields as the sum of the quantity of an article of the grouped records. I get an #error# in a control on the form where I want to display the sum of this sum. TxtExample =sum(SumOfQuantity). I understand that I can't sum a calculated control but I would argue this is not a calculated control. I have been wrong before though.... Any help would be very much apprciated, thanks in advance
1
3311
by: z.ghulam | last post by:
I've designed a query which merely counts the number of different types of orders. What I am after is a way of getting a Grand Total which will be the Sum of all the totals. It sounds simple enough, but I just cannot seem to get it working - I designed the Query using the Query builder, but have put the SQL below if it helps. Any help / advice would be greatly appreciated.
0
1090
by: Stan | last post by:
I am trying to design a query that will, for a selected month, give me the sum total of a Number field "0 to 18". The criteria for the month is one that this group helped me with at an early date. Following is the SQL for the query as I now stand. SELECT ., . FROM WHERE (((Format(,"mm/yyyy"))=)); I have tried several expressions and none seem to work. Can you give
2
3860
by: glen.riddell | last post by:
I have 2 queries, for the sake of this post I will refer to them as query1 and query2. Basically query1 returns a number of results from tables which are grouped and then query2 queries query1 and is expected to sum the number of hours. query1 returns the following rows: PersonID StartDate EndDate Hours =========================================== 801 07/09/06 11/12/06 420
1
1394
by: Dan2kx | last post by:
Hello, i am need to sum some data as so.. StaffID, RequestID, MinutesUsed StaffID limited by combobox on form, requestID (contains a duplicate numbers reletive to the point the record is created e.g. 10 records added contain "1" next time the procedure (for that staff) is records will be "2"), Minutes used is what i want to sum and i want to sum by limiting the sum to the highest RecordID ( it sums all entries when i do it) eg...
1
2748
by: bbatson | last post by:
Hello, I have searched for help on this and have not been successful in finding an answer to my particular problem. I am trying to compute a running sum of sales in a query. Here is the query output as of now: http://img126.imageshack.us/img126/7462/post1jh8.jpg
6
2363
by: feed the inferno | last post by:
i think im confusing myself here but ill try my best to explain i have a form where cds can be purchased, within it is a subform which allows a user to choose from a combo box of all the cds Now i got a textbox to display the sum of the prices using =sum() but i need to put that sum into a query, i understand you can do the total: + in order to add prices up but because my prices are based within a sub form i only have 1 price field and...
0
1419
by: Julian Mishke | last post by:
Hello, I am very new to this and having problems with the SUM and MAX in my query: SELECT Score.performerId, Performer.performerName, Performer.countrycode, Country.countryName, Event.eventName, Score.points FROM Score, Performer, Country, Event WHERE points = (SELECT MAX(points) FROM Score WHERE roundName = 'Final') AND roundName = 'Final' AND Score.performerId=Performer.performerId AND Performer.countryCode=Country.countryCode
0
8473
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8911
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8667
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6222
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5692
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4402
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2808
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2048
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.