473,382 Members | 1,396 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,382 software developers and data experts.

query for tot

22
Hello All, I have run into an issue

I have a Product table which captures all incoming stock
I have a Outgoing table which captures all outgoing stock

I have created a query from the product and outgoing tables and in a colum by itself have totalled the amount of stock per product however, what I am needing to see is

1. a report that collates all specific type of stock for example Passenger and includes any outgoing.

I have so far got this far as per below, what I am finding is info is now being duplicated and showing multiple entries for any one particular item...i would appreciate help on this one

Expand|Select|Wrap|Line Numbers
  1. SELECT   Products.[Product Name]
  2.         ,OutgoingTBL.Type
  3.         ,OutgoingTBL.Size
  4.         ,Products.QTY
  5.         ,OutgoingTBL.[Qty Out]
  6.         ,Sum([products]![Qty]-nz([Qty Out],0)) AS [Current Tyre Type in stock]
  7.  
  8. FROM     Products INNER JOIN OutgoingTBL ON Products.Type = OutgoingTBL.Type
  9.  
  10. GROUP BY Products.[Product Name]
  11.         ,OutgoingTBL.Type
  12.         ,OutgoingTBL.Size
  13.         ,Products.QTY
  14.         ,OutgoingTBL.[Qty Out]
  15.  
  16. HAVING   (((OutgoingTBL.Type) Like "*" & [Enter Type Allterrain 4WD, Light Truck, MUDTerrain, Passenger, SUV, Tube] & "*"));
Jul 16 '10 #1
3 1160
jimatqsi
1,271 Expert 1GB
Because you included .qty and .qtyout in your grouping you are seeing one row for every change in either quantity. Remove those two from your Group By.


Jim
Jul 16 '10 #2
heart01
22
Cheers Jimatqsi, I removed the .qty and .qtyout from the grouping and I am receiving error message stating i tried to execute a query that does not include specified QTY as aggregate function...any heads up on this perhaps
Jul 17 '10 #3
patjones
931 Expert 512MB
Anything that you remove from the GROUP BY clause must be removed from the SELECT clause as well. Otherwise you will obtain an error.

In your situation, it almost seems as though you don't even need to group by anything. The way you have your query written out right now, the grouping will yield sensible results only if there are multiple records containing the same entries for Product Name, Type, Size, QTY, and Qty Out all at the same time...because the idea behind GROUP BY is that it combines like records into a summary record.

However, if even one of those is different, it will not be included in the grouping. For instance, if you perform a grouping on:

Product Name Size Type QTY Qty Out

4WD 35 A 34 23
4WD 35 A 34 23
4WD 35 A 34 18



...then you will end up with two records: one that combines the first two records in the original set, and another that is simply the third record. This is why jimatsqi asked for you to remove QTY and Qty Out from the grouping...each change in those entries will result in a different record in the output.

Pat
Jul 19 '10 #4

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

Similar topics

2
by: jaysonsch | last post by:
Hello! I am having some problems with a database query that I am trying to do. I am trying to develop a way to search a database for an entry and then edit the existing values. Upon submit, the...
29
by: shank | last post by:
1) I'm getting this error: Syntax error (missing operator) in query expression on the below statement. Can I get some advice. 2) I searched ASPFAQ and came up blank. Where can find the "rules"...
9
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use...
3
by: Harvey | last post by:
Hi, I try to write an asp query form that lets client search any text-string and display all pages in my web server that contain the text. I have IIS 6.0 on a server 2003. The MSDN site says...
14
by: Dave Thomas | last post by:
If I have a table set up like this: Name | VARCHAR Email | VARCHAR Age | TINYINT | NULL (Default: NULL) And I want the user to enter his or her name, email, and age - but AGE is optional. ...
0
by: starace | last post by:
I have designed a form that has 5 different list boxes where the selections within each are used as criteria in building a dynamic query. Some boxes are set for multiple selections but these list...
15
by: Richard Hollenbeck | last post by:
I tried to ask this question before on the 14th of January but I never got a reply. I'm still struggling with the problem. I'll try to rephrase the question: I have a crosstab query with rows...
6
by: jjturon | last post by:
Can anyone help me?? I am trying to pass a Select Query variable to a table using Dlookup and return the value to same select query but to another field. Ex. SalesManID ...
3
by: cover | last post by:
I have a table with 50 fields that receive input depending on whether that input came in from a 'shaker' form or a 'conveyor' form. Input from the 'conveyor' form might populate 25 fields while...
4
by: Stan | last post by:
I am using MS Office Access 2003 (11.5614). My basic question is can I run a query of a query datasheet. I want to use more that one criteria and can not get that query to work. I thought I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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

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.