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

Issues with aggreagates again

22
Hi all I received answer previously regarding calculations that show on a form and then in a query. I have everything working on the form showing the calcs and I have used two queries off one another as previously suggest and entered the SQL details as previously suggested everything works excllent. I thought that I had covered everything however, I have to include another field in the table named "power cost per unit" which I have done and updated all reports and queries or so I thought. this field has to be calculated on the Grand Total divided by the QTY to get the cost per unit gst and freight incl. the other thing I have to try figure out is I need to figure out how to separately enter a mark up price (this markup price will be a dynamic figure). I have been round and round in circles and keep getting messages about not being able to something or rather about aggregegates and at times i have the syntax error. I know this is long as I post the two queries that the database works from however could someone please cast their trained and experienced eye over it and advise where I am going wrong? (I have highlighted the two areas below where I have entered the information of the field that I require.

PRODUCT TOTALS QUERY
SELECT [Products_QU_foundationnot in use].ID, [Products_QU_foundationnot in use].[Date Recvd], [Products_QU_foundationnot in use].[Invoice NO], [Products_QU_foundationnot in use].Suppliers, [Products_QU_foundationnot in use].[Product Name], [Products_QU_foundationnot in use].Type, [Products_QU_foundationnot in use].Size, [Products_QU_foundationnot in use].[Load Index], [Products_QU_foundationnot in use].Type, [Products_QU_foundationnot in use].[Supplier Cost Per Unit], [Products_QU_foundationnot in use].QTY, [Products_QU_foundationnot in use].GST, [Products_QU_foundationnot in use].[gst per item], [Products_QU_foundationnot in use].[Freight Cost], [Products_QU_foundationnot in use].[Freight Cost Per Item], Sum(([Supplier Cost Per Unit]*[QTY])+[GST]+[Freight Cost]) AS [GRAND TOTAL Freight plus GST incl], [Products_QU_foundationnot in use].Comments, [Products_QU_foundationnot in use].[Date Outgoing], [Products_QU_foundationnot in use].[Type Out], [Products_QU_foundationnot in use].[Qty Out], [Products_QU_foundationnot in use].Freight, [Products_QU_foundationnot in use].[Freight Send Cost], [Products_QU_foundationnot in use].[Remaining Stock], Sum(([GRAND TOTAL Freight plus GST incl]/[QTY]) AS [power cost per unit]FROM [Products_QU_foundationnot in use]
GROUP BY [Products_QU_foundationnot in use].ID, [Products_QU_foundationnot in use].[Date Recvd], [Products_QU_foundationnot in use].[Invoice NO], [Products_QU_foundationnot in use].Suppliers, [Products_QU_foundationnot in use].[Product Name], [Products_QU_foundationnot in use].Type, [Products_QU_foundationnot in use].Size, [Products_QU_foundationnot in use].[Load Index], [Products_QU_foundationnot in use].Type, [Products_QU_foundationnot in use].[Supplier Cost Per Unit], [Products_QU_foundationnot in use].QTY, [Products_QU_foundationnot in use].GST, [Products_QU_foundationnot in use].[gst per item], [Products_QU_foundationnot in use].[Freight Cost], [Products_QU_foundationnot in use].[Freight Cost Per Item], [Products_QU_foundationnot in use].Comments, [Products_QU_foundationnot in use].[Date Outgoing], [Products_QU_foundationnot in use].[Type Out], [Products_QU_foundationnot in use].[Qty Out], [Products_QU_foundationnot in use].Freight, [Products_QU_foundationnot in use].[Freight Send Cost], [Products_QU_foundationnot in use].[Remaining Stock], [Products_QU_foundationnot in use].[Freight Company], [Products_QU_foundationnot in use].[power cost per unit];

THEN IN THE OTHER QUERY NAMED Products_QU_foundationnot in use

SELECT Products.ID, Products.[Date Recvd], Products.[Invoice NO], Products.Suppliers, Products.[Product Name], Products.Type, Products.Size, Products.[Load Index], Products.[Supplier Cost Per Unit], Products.QTY, Sum([Supplier Cost Per Unit]*[Qty]*0.1) AS GST, ([GST]/[Qty]) AS [gst per item], Products.[Freight Cost], Sum([Freight Cost]/[QTY]) AS [Freight Cost Per Item], Products.[GRAND TOTAL Freight plus GST incl], Products.[Freight Company], Products.Comments, Products.[Date Outgoing], Products.[Type Out], Products.[Qty Out], Products.Freight, Products.[Freight Send Cost], Sum([Qty]-[Qty Out]) AS [Remaining Stock], Products.[ power cost per unit]
FROM Products
GROUP BY Products.ID, Products.[Date Recvd], Products.[Invoice NO], Products.Suppliers, Products.[Product Name], Products.Type, Products.Size, Products.[Load Index], Products.[Supplier Cost Per Unit], Products.QTY, Products.[Freight Cost], Products.[GRAND TOTAL Freight plus GST incl], Products.[Freight Company], Products.Comments, Products.[Date Outgoing], Products.[Type Out], Products.[Qty Out], Products.Freight, Products.[Freight Send Cost], Products.[GRAND TOTAL Freight plus GST incl], Products.[Freight Cost Per Item], Products.[power cost per unit];
many many many thanks
Jun 25 '10 #1
6 1297
colintis
255 100+
The GROUP BY in the 1st query may have error because [Products_QU_foundationnot in use].[power cost per unit] is not part of the selected field, you can try removing [Products_QU_foundationnot in use] or the whole thing and see if it works.

Also, in the select fields of your 2nd query, i saw there's a space after the [ in Products.[ power cost per unit] (if this is copied directly from your query). Try and see if it works.

Remember to use [code] tag with the codes :)
Jun 25 '10 #2
heart01
22
hello Colintis I tried your suggestion and I am still having issues...I have played around a little further and now I can see the calculations in the query but all of the other calc on the form have dissapeared (didnt touch any of these on the form) and are showing in the box the "#name?" .. still cannot figured it out my apologies

cheers
deb
Jun 25 '10 #3
colintis
255 100+
@heart01
can you post the code that you wrote? maybe its variable type error or some code settings not correct.
Jun 25 '10 #4
heart01
22
@colintis
Yes thank you. I still have not complete understanding of how it all goes together so I appreciate the help...here is the codes for the two queries that have been written...
QUERY ONE

Expand|Select|Wrap|Line Numbers
  1. SELECT [Products_QU_foundationnot in use].ID, [Products_QU_foundationnot in use].[Date Recvd], [Products_QU_foundationnot in use].[Invoice NO], [Products_QU_foundationnot in use].Suppliers, [Products_QU_foundationnot in use].[Product Name], [Products_QU_foundationnot in use].Type, [Products_QU_foundationnot in use].Size, [Products_QU_foundationnot in use].[Load Index], [Products_QU_foundationnot in use].Type, [Products_QU_foundationnot in use].[Supplier Cost Per Unit], [Products_QU_foundationnot in use].QTY, [Products_QU_foundationnot in use].GST, [Products_QU_foundationnot in use].[gst per item], [Products_QU_foundationnot in use].[Freight Cost], [Products_QU_foundationnot in use].[Freight Cost Per Item], [GRAND TOTAL Freight plus GST incl]/[QTY] AS [Cost Per Unit], Sum(([Supplier Cost Per Unit]*[QTY])+[GST]+[Freight Cost]) AS [GRAND TOTAL Freight plus GST incl], [Products_QU_foundationnot in use].Comments, [Products_QU_foundationnot in use].[Date Outgoing], [Products_QU_foundationnot in use].[Type Out], [Products_QU_foundationnot in use].[Qty Out], [Products_QU_foundationnot in use].Freight, [Products_QU_foundationnot in use].[Freight Send Cost], [Products_QU_foundationnot in use].[Remaining Stock]
  2. FROM [Products_QU_foundationnot in use]
  3. GROUP BY [Products_QU_foundationnot in use].ID, [Products_QU_foundationnot in use].[Date Recvd], [Products_QU_foundationnot in use].[Invoice NO], [Products_QU_foundationnot in use].Suppliers, [Products_QU_foundationnot in use].[Product Name], [Products_QU_foundationnot in use].Type, [Products_QU_foundationnot in use].Size, [Products_QU_foundationnot in use].[Load Index], [Products_QU_foundationnot in use].Type, [Products_QU_foundationnot in use].[Supplier Cost Per Unit], [Products_QU_foundationnot in use].QTY, [Products_QU_foundationnot in use].GST, [Products_QU_foundationnot in use].[gst per item], [Products_QU_foundationnot in use].[Freight Cost], [Products_QU_foundationnot in use].[Freight Cost Per Item], [Products_QU_foundationnot in use].Comments, [Products_QU_foundationnot in use].[Date Outgoing], [Products_QU_foundationnot in use].[Type Out], [Products_QU_foundationnot in use].[Qty Out], [Products_QU_foundationnot in use].Freight, [Products_QU_foundationnot in use].[Freight Send Cost], [Products_QU_foundationnot in use].[Remaining Stock], [Products_QU_foundationnot in use].[Freight Company];
QUERY TWO (the highlight in bold is what I have added "cost per item" was prev as above power cost per unit)

Expand|Select|Wrap|Line Numbers
  1. SELECT Products.ID, Products.[Date Recvd], Products.[Invoice NO], Products.Suppliers, Products.[Product Name], Products.Type, Products.Size, Products.[Load Index], Products.[Supplier Cost Per Unit], Products.QTY, Sum([Supplier Cost Per Unit]*[Qty]*0.1) AS GST, ([GST]/[Qty]) AS [gst per item], Products.[Freight Cost], Sum([Freight Cost]/[QTY]) AS [Freight Cost Per Item], Products.[GRAND TOTAL Freight plus GST incl], Products.[Freight Company], Products.Comments, Products.[Date Outgoing], Products.[Type Out], Products.[Qty Out], Products.Freight, Products.[Freight Send Cost], Sum([Qty]-[Qty Out]) AS [Remaining Stock], Products.[Cost Per Unit], [GRAND TOTAL Freight plus GST incl]/[QTY]FROM Products
  2. GROUP BY Products.ID, Products.[Date Recvd], Products.[Invoice NO], Products.Suppliers, Products.[Product Name], Products.Type, Products.Size, Products.[Load Index], Products.[Supplier Cost Per Unit], Products.QTY, Products.[Freight Cost], Products.[GRAND TOTAL Freight plus GST incl], Products.[Freight Company], Products.Comments, Products.[Date Outgoing], Products.[Type Out], Products.[Qty Out], Products.Freight, Products.[Freight Send Cost], Products.[Freight Cost Per Item], Products.[Cost Per Unit];
So as mentioned Now all my queries work but the calculations on the forms have now dissapeared and just now showing #name?,,,,,,,,,,
Jun 25 '10 #5
heart01
22
@heart01
to hard basket?
Jun 27 '10 #6
heart01
22
Well it appears that all it working now. I have no idea what I did to get it working however, all calculations are now visible on the form and both queries that I have to use to have the calcs working on the form and the queries for the reports see to be working ... Ill just go back into the database another time just to make sure...thanking you for all help ...kind regards deb
Jun 28 '10 #7

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

Similar topics

5
by: sandy | last post by:
Hi All, I am a newbie to MySQL and Python. At the first place, I would like to know what are the general performance issues (if any) of using MySQL with Python. By performance, I wanted to...
6
by: Microsoft News | last post by:
Hi, I have been using several http server code examples from the web, include one from msdn, and I can't seem to get a simple http server thread working. I can connect the server successful...
7
by: David Laub | last post by:
I have stumbled across various Netscape issues, none of which appear to be solvable by tweaking the clientTarget or targetSchema properties. At this point, I'm not even interested in "solving"...
10
by: Robert | last post by:
I have an app that was originally 1.1, now migrated to 2.0 and have run into some sporadic viewstate errors...usually saying the viewstate is invalid, eventvalidation failed or mac error. My web...
18
by: Larry Herbinaux | last post by:
I'm having issues with garbage collection with my long-standing service process. If you could review and point me in the right direction it would be of great help. If there are any helpful...
8
by: GaryDean | last post by:
In an 2.0 asp app I used vs.net 2005 to create a TableAdapter:Dataset in my App_code directory. I also created a new vb class in that same directory. I have two issues: 1. I notice that there...
1
by: David Thielen | last post by:
Hi; I would like to display a page then immediately cause a post back (the 1st page will have a big "working..." on it, then in the post back do my query which will take a couple of seconds, and...
7
by: Martien van Wanrooij | last post by:
I have been faced a couple of times with the situation that I wanted to write a script and was worried about a too frequent opening and closing mysql connections. To give some examples: 1)I...
1
by: =?Utf-8?B?QmlsbHkgWmhhbmc=?= | last post by:
Is this a managed post?
2
by: time_error | last post by:
Please bear with me - I’m quite new to MSSQL and the whole db domain. The db itself is pretty simple. There are approx. 15 tables. The two largest tables’ holds a total of 10 mill. entries. ...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
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...

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.