A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Aggregate Function



 
 
Thread Tools Display Modes
  #1  
Old June 9th, 2006, 07:27 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default Aggregate Function

Hi all. I've tried finding an answer to this and can't find one somewhat
close. I'm getting an "You tried to execute a query that does not include the
specified expression name as part of an aggregate function." error . I've
put in some IIf statements to prevent Overflow or the Can Not Divide by Zero
however now said Function problem exists. Why am I getting this issue? Any
help is very much appreciated.

Here's the drill down on the SQL:

Sum (IIf([HoursWorkedCoating]=0,0,((((([TotalVials]*30)-[CoatingWaste])*0.
034/128)*[CoatingVOC])/[HoursWorkedCoating])+(((([AmountMixed]-
[AmountCollected])*0.034/128)*[CleaningVOC])/IIf([HoursWorkedCleaning]=0,0,
[HoursWorkedCleaning])))) AS TotalVOCEmissionHour,

and here is the whole Query if needed:

SELECT CleanRoom.CleanRoomID, CleanRoom.Date, Year([Date]) AS [Year],
CleanRoom.CoatingID, CleanRoom.TotalVials, CleanRoom.CoatingWaste, CleanRoom.
HoursWorkedCoating, CleanRoom.Date2, CleanRoom.CleaningID, CleanRoom.
AmountMixed, CleanRoom.AmountCollected, CleanRoom.HoursWorkedCleaning, Sum(((
([TotalVials]*30)-[CoatingWaste])*0.034/128)*[CoatingVOC]) AS
CoatingVOCEmission, IIf ([HoursWorkedCoating]=0,0,Sum( ((([TotalVials]*30)-
[CoatingWaste])*0.034/128)*[CoatingVOC])/[HoursWorkedCoating])) AS
CoatingVOCEmissionHour, Sum((((([TotalVials]*30)-[CoatingWaste])*0.034/128)*
[CoatingVOC])*0.0005) AS CoatingTonsYear, Sum((([AmountMixed]-
[AmountCollected])*0.034/128)*[CleaningVOC]) AS CleaningVOCEmission, Sum((((
[AmountMixed]-[AmountCollected])*0.034/128)*[CleaningVOC])/2000) AS
CleaningTonsYear, IIf ([HoursWorkedCleaning]=0,0,Sum(((([AmountMixed]-
[AmountCollected])*0.034/128)*[CleaningVOC])/[HoursWorkedCleaning])) AS
CleaningVOCEmissionHours, Sum (IIf([HoursWorkedCoating]=0,0,((((([TotalVials]
*30)-[CoatingWaste])*0.034/128)*[CoatingVOC])/[HoursWorkedCoating])+((((
[AmountMixed]-[AmountCollected])*0.034/128)*[CleaningVOC])/IIf(
[HoursWorkedCleaning]=0,0,[HoursWorkedCleaning])))) AS TotalVOCEmissionHour,
Sum((((([TotalVials]*30)-[CoatingWaste])*0.034/128)*[CoatingVOC])+(((
[AmountMixed]-[AmountCollected])*0.034/128)*[CleaningVOC])) AS
TotalVOCEmission, Sum(((((([TotalVials]*30)-[CoatingWaste])*0.034/128)*
[CoatingVOC])+((([AmountMixed]-[AmountCollected])*0.034/128)*[CleaningVOC]))
/2000) AS TonsYear
FROM (CoatingChemicals INNER JOIN CleanRoom ON CoatingChemicals.CoatingID =
CleanRoom.CoatingID) INNER JOIN CleaningChemicals ON CleanRoom.CleaningID =
CleaningChemicals.CleaningID
GROUP BY CleanRoom.CleanRoomID, CleanRoom.Date, Year([Date]), CleanRoom.
CoatingID, CleanRoom.TotalVials, CleanRoom.CoatingWaste, CleanRoom.
HoursWorkedCoating, CleanRoom.Date2, CleanRoom.CleaningID, CleanRoom.
AmountMixed, CleanRoom.AmountCollected, CleanRoom.HoursWorkedCleaning;

--
Later,

Darrin

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200606/1
  #2  
Old June 11th, 2006, 05:09 AM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default Aggregate Function

Try moving the IIF inside the Sum functions. because of the Grouping, it is
looking for either a group field or an aggregate function. j.

"virtualkeeper via AccessMonster.com" wrote:

Hi all. I've tried finding an answer to this and can't find one somewhat
close. I'm getting an "You tried to execute a query that does not include the
specified expression name as part of an aggregate function." error . I've
put in some IIf statements to prevent Overflow or the Can Not Divide by Zero
however now said Function problem exists. Why am I getting this issue? Any
help is very much appreciated.

Here's the drill down on the SQL:

Sum (IIf([HoursWorkedCoating]=0,0,((((([TotalVials]*30)-[CoatingWaste])*0.
034/128)*[CoatingVOC])/[HoursWorkedCoating])+(((([AmountMixed]-
[AmountCollected])*0.034/128)*[CleaningVOC])/IIf([HoursWorkedCleaning]=0,0,
[HoursWorkedCleaning])))) AS TotalVOCEmissionHour,

and here is the whole Query if needed:

SELECT CleanRoom.CleanRoomID, CleanRoom.Date, Year([Date]) AS [Year],
CleanRoom.CoatingID, CleanRoom.TotalVials, CleanRoom.CoatingWaste, CleanRoom.
HoursWorkedCoating, CleanRoom.Date2, CleanRoom.CleaningID, CleanRoom.
AmountMixed, CleanRoom.AmountCollected, CleanRoom.HoursWorkedCleaning, Sum(((
([TotalVials]*30)-[CoatingWaste])*0.034/128)*[CoatingVOC]) AS
CoatingVOCEmission, IIf ([HoursWorkedCoating]=0,0,Sum( ((([TotalVials]*30)-
[CoatingWaste])*0.034/128)*[CoatingVOC])/[HoursWorkedCoating])) AS
CoatingVOCEmissionHour, Sum((((([TotalVials]*30)-[CoatingWaste])*0.034/128)*
[CoatingVOC])*0.0005) AS CoatingTonsYear, Sum((([AmountMixed]-
[AmountCollected])*0.034/128)*[CleaningVOC]) AS CleaningVOCEmission, Sum((((
[AmountMixed]-[AmountCollected])*0.034/128)*[CleaningVOC])/2000) AS
CleaningTonsYear, IIf ([HoursWorkedCleaning]=0,0,Sum(((([AmountMixed]-
[AmountCollected])*0.034/128)*[CleaningVOC])/[HoursWorkedCleaning])) AS
CleaningVOCEmissionHours, Sum (IIf([HoursWorkedCoating]=0,0,((((([TotalVials]
*30)-[CoatingWaste])*0.034/128)*[CoatingVOC])/[HoursWorkedCoating])+((((
[AmountMixed]-[AmountCollected])*0.034/128)*[CleaningVOC])/IIf(
[HoursWorkedCleaning]=0,0,[HoursWorkedCleaning])))) AS TotalVOCEmissionHour,
Sum((((([TotalVials]*30)-[CoatingWaste])*0.034/128)*[CoatingVOC])+(((
[AmountMixed]-[AmountCollected])*0.034/128)*[CleaningVOC])) AS
TotalVOCEmission, Sum(((((([TotalVials]*30)-[CoatingWaste])*0.034/128)*
[CoatingVOC])+((([AmountMixed]-[AmountCollected])*0.034/128)*[CleaningVOC]))
/2000) AS TonsYear
FROM (CoatingChemicals INNER JOIN CleanRoom ON CoatingChemicals.CoatingID =
CleanRoom.CoatingID) INNER JOIN CleaningChemicals ON CleanRoom.CleaningID =
CleaningChemicals.CleaningID
GROUP BY CleanRoom.CleanRoomID, CleanRoom.Date, Year([Date]), CleanRoom.
CoatingID, CleanRoom.TotalVials, CleanRoom.CoatingWaste, CleanRoom.
HoursWorkedCoating, CleanRoom.Date2, CleanRoom.CleaningID, CleanRoom.
AmountMixed, CleanRoom.AmountCollected, CleanRoom.HoursWorkedCleaning;

--
Later,

Darrin

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200606/1

  #3  
Old June 12th, 2006, 04:03 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default Aggregate Function

Jen wrote:
Try moving the IIF inside the Sum functions. because of the Grouping, it is
looking for either a group field or an aggregate function. j.


Thanks Jen, that did the trick for the error message but I'm not back at my
overflow problem due to dividing by zero.

--
Later,

Darrin

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200606/1
  #4  
Old June 12th, 2006, 04:51 PM posted to microsoft.public.access.queries
external usenet poster
 
Posts: n/a
Default Aggregate Function

Sorry, typo there. Meant to say: Thanks Jen, that did the trick for the
error message but I'm now back at my
overflow problem. Don't know what the overflow is. It looks like I've taken
care of the divide by zero problem.

virtualkeeper wrote:
Try moving the IIF inside the Sum functions. because of the Grouping, it is
looking for either a group field or an aggregate function. j.


Thanks Jen, that did the trick for the error message but I'm not back at my
overflow problem due to dividing by zero.


--
Later,

Darrin

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200606/1
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom functions calculating time arguments Help Desperate Bill_De Worksheet Functions 12 April 25th, 2006 02:22 AM
Percentile Aggregate Function [email protected] Running & Setting Up Queries 3 February 28th, 2006 09:02 PM
How Do You Order an Aggregate Function A Boy Named Joe Setting Up & Running Reports 2 August 17th, 2005 02:46 PM
Automatically up date time in a cell Mark General Discussion 5 May 12th, 2005 12:26 AM
DISTINCT option of an aggregate function in Access 2003 [email protected] Running & Setting Up Queries 1 May 5th, 2005 04:46 PM


All times are GMT +1. The time now is 08:22 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.