Results 1 to 8 of 8
  1. #1
    Fais is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    7

    Question Aggregation function issue in Access

    Hello,
    i have 6 columns in my table and i need to run a query as mentioned below but i get an error message while running, please assist. thanks.

    select
    column1,
    trim(column2) as column2_trim, ---uses a combination of trim, instr and mid functions to drive a text from a field
    count(column2_trim), ---- i want to do a count on the previous column


    column3,
    column4,
    sum(column5),
    ABS(column5)
    from table1
    where column1 = 'sample1'
    group by
    column1,
    column3,
    column4;


    i get the error:
    you tried to execute a query that does not include the specified expression 'column2_trim' as part of an aggregate function.

    can you please point me to what im doing wrong? thanks.

  2. #2
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Suggestion Not tested.

    Change count(column2_trim) to count(column2).

  3. #3
    Fais is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    7
    Hi, i have tried that as well, it still doesn't work.

  4. #4
    lfpm062010 is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Location
    US
    Posts
    415
    Did you try group by trim(column2)?

  5. #5
    Fais is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    7

    Question Create a aggregation based on previous column

    Hello, i am trying to achieve the following in Access 2010. Please assist.

    Open date is calculated based on order date and ship date, how can i put together a query which achieves this output?

    Open_Date Count Amount Absolute_Amount
    0 -> 30 0 0.00 0.00
    31 -> 90 3 33359 33359
    91 -> 180 1 (4773) 4773

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    What is name of the query were Open_Date is calculated?

    SELECT Open_Date, Count(*) AS CountRecs, Sum(Amount) AS SumAmt FROM queryname GROUP BY Open_Date;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    Fais is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    7
    Thank you for the answer, i want all of this calculated in one query. so 1 query should be able to generate the above table, how to do that?
    '0 > 30'
    '31 >90'
    '91 > 180'

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Maybe:

    SELECT {calculation} AS Open_Date, Count(*) AS CountRecs, Sum(Amount) AS SumAmt FROM queryname GROUP BY {calculation};

    Substitute your expression in place of {calculation}.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Aggregation Query doubt
    By akshayajmani in forum Access
    Replies: 4
    Last Post: 10-24-2012, 11:52 PM
  2. date function return value issue
    By live2ride in forum Access
    Replies: 3
    Last Post: 10-24-2012, 07:06 PM
  3. Replies: 4
    Last Post: 10-02-2012, 12:30 AM
  4. Different aggregation levels
    By mod2000 in forum Queries
    Replies: 1
    Last Post: 08-11-2011, 07:27 AM
  5. Keep together issue (Access 12)
    By alpha in forum Reports
    Replies: 2
    Last Post: 06-02-2009, 08:21 AM

Tags for this Thread

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