Results 1 to 3 of 3
  1. #1
    boutwater is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2011
    Posts
    6

    aggregate error due to function


    Is there some way to do this:

    SELECT (sum(d.cartonsshipped)/m.ctnperskid) AS PalletCount, itemnumber, shipdate
    FROM orderdata d
    inner join itemmaster m
    on d.itemnumber = m.itemnumber
    GROUP BY d.itemnumber, d.shipdate
    HAVING (sum(d.cartonsshipped)/m.ctnperskid) > 0
    ORDER BY d.shipdate, d.itemnumber;

    and not get the aggregate error (3122). Im guessing it's giving me the error because i try to do a function in the select area. How can I get around this. Thank you in advance,

    Ben

  2. #2
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    No you're getting the error because your dividing an Aggregate by a field. You will need to change sum(d.cartonsshipped)/m.ctnperskid to
    (sum(d.artonsshipped)/sum(m.ctsperskid)) Or some aggregation of m.ctsperskid depending on what your data/needs are.

  3. #3
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    And also you would need to make sure your divisor is never null or equal to 0. Otherwise you would need to use some IIF statements to ensure that (because you can't divide by null or by 0).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Aggregate function returns duplicate values
    By lokiluke in forum Queries
    Replies: 3
    Last Post: 09-16-2011, 09:40 AM
  2. Replies: 0
    Last Post: 04-25-2011, 07:58 PM
  3. an aggregate function error message
    By newtoAccess in forum Queries
    Replies: 1
    Last Post: 11-27-2010, 05:18 PM
  4. Replies: 2
    Last Post: 08-05-2010, 08:16 AM
  5. Access SQL Query - Aggregate function
    By jack in forum Access
    Replies: 0
    Last Post: 11-10-2009, 08:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums