Quick addition problem

Infinite

More left to learn.
Local time
Today, 12:00
Joined
Mar 16, 2015
Messages
402
Hello, I have
SELECT tblItems.Model, (Nz(qryEcwidTotal.SumE,0)) AS EcwidTotal, (Nz(qryShowSalesTotals.SumS,0)) AS ShowTotal, (Nz(qryAmazonTotal.SumOfquantity,0)) AS AmazonTotal, ([EcwidTotal]+[ShowTotal])+[AmazonTotal] AS Totalz
FROM ((tblItems LEFT JOIN qryShowSalesTotals ON tblItems.Model = qryShowSalesTotals.Model) LEFT JOIN qryAmazonTotal ON tblItems.Model = qryAmazonTotal.Model) LEFT JOIN qryEcwidTotal ON tblItems.Model = qryEcwidTotal.Model;

that. Problem I have is in the picture, its kinda weird, never had it before. Any idea what im doing wrong?
 

Attachments

  • Capture.PNG
    Capture.PNG
    39.1 KB · Views: 158
A quick look at your png file suggests, to me at least, that you are concatenating strings and not doing any arithmetic/addition.
You have not shown readers the make up of some query(s)
qryEcwidTotal, qryAmazonTotal, qryShowSalesTotals so we have no idea of what may be involved. And there is no description of the business/processes involved to help put your post into context.

In your png file the totals EcwidTotal, AmazonTotal and ShowTotal are all left justified which indicates they are all text data type. Your Totalz is simply a concatenation of these.
For example , the first line(Model M1911) for EcwidTotal, AmazonTotal and ShowTotal has values 61, 49 and 610 with the Totalz being 6161049. And this is really, a concatenation of EcwidTotal & ShowTotal & AmazonTotal in this order.

To do arithmetic/addition, you need number data type fields/variables.

It appears to me that you have some design and data type issues that are causing you considerable grief.
 
Code:
SELECT tblItems.Model, Sum(tblAmazonOrders.quantity) AS SumOfquantity
FROM tblItems LEFT JOIN tblAmazonOrders ON tblItems.Model = tblAmazonOrders.description
GROUP BY tblItems.Model;

That is the query for all 3 of those. EcwidTotal, AmazonTotal and ShowTotal.
I also just checked (changed one) and there all number fields, and that is why im confused...Those 4 query's make up all of it, so I dont think I need more...Like I said, there all Number Fields, and the item is all Text fields, so im pretty sure they should all my added up correct.

left justified
And what is that?



Code:
SELECT tblItems.Model, Sum(tblEcwidOrders.quantity) AS SumE
FROM tblItems LEFT JOIN tblEcwidOrders ON tblItems.Model = tblEcwidOrders.name
GROUP BY tblItems.Model;


Code:
SELECT tblItems.Model, Sum(tblShowSales.Quantity) AS SumS
FROM tblItems LEFT JOIN tblShowSales ON tblItems.Model = tblShowSales.Item
GROUP BY tblItems.Model;

Just the other 2 query's in case any one wanted to make sure.


And there is no description of the business/processes involved to help put your post into context.

Ok, reason for this is so I can get the totals of all items sold, and seeing as (unwisely) I dont have tblAmazonOrders, tblEcwidOrders and tblShowSales all in 1 table called tblSales (or something along those lines) I cant just get the total of all the quantity sold. I plan on doing that, but if im going to do that, I should first find out why this is just (like you said) all those numbers "added" together.
 

Users who are viewing this thread

Back
Top Bottom