Results 1 to 6 of 6
  1. #1
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286

    ERROR when trying to do Average in Query

    Hello, i keep getting this message "you tried to execute query that doesnt include specific expression ""....

    everything looks fine but i dont understand why it is not averaging. I want to average the number of days late, everything else

    heres a copy of the sql, pic is also attached. thanks!




    SELECT qryPiece1.CHANNEL_ROOT_ID, Format([problem_report_event_dttm],"mm/dd/yyyy") AS [Event Date], qryPiece1.PROBLEM_REPORT_EVENT_TXT, qryPiece1.CycleDay, qryPiece1.LastReadDate, qryDay4Report_Piece2.[Due Date], Date()-[Due Date] AS [Days Late], Avg([Days Late]) AS Expr1
    FROM qryDay4Report_Piece2 INNER JOIN qryPiece1 ON (qryDay4Report_Piece2.Month = qryPiece1.Month) AND (qryDay4Report_Piece2.Serial = qryPiece1.CycleDay)
    WHERE (((qryPiece1.PROBLEM_REPORT_EVENT_TXT) Not Like "*sxv0*" And (qryPiece1.PROBLEM_REPORT_EVENT_TXT) Not Like "*byt2*" And (qryPiece1.PROBLEM_REPORT_EVENT_TXT) Not Like "*sef4*" And (qryPiece1.PROBLEM_REPORT_EVENT_TXT) Not Like "*jdbj*" And (qryPiece1.PROBLEM_REPORT_EVENT_TXT) Not Like "*gasg*") AND ((qryPiece1.LastReadDate)<[Due Date]) AND ((Date()-[Due Date])>=1));

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You must use the Totals function - click on the Greek-looking "E" icon and see what happens.

  3. #3
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286
    i tried that and it says

    cant have aggregate function in group by clause (avg(avg([days late])) if i change it to "avg"

    and

    cant have aggregate function in group by clause (avg([days late])) if i just leave it as group by

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Your "avg" cannot be in the field name line, it must be in the totals line.

  5. #5
    taimysho0 is offline Competent Performer
    Windows XP Access 2000
    Join Date
    Nov 2011
    Posts
    286
    the only thing is that it does not average the whole column, it just averages the row?

  6. #6
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    More than the row - you are grouping by something, otherwise why would you need averages? Your picture is a little small, but it looks as though you would remove the last column and put the "avg" on the Days late calc column.

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

Similar Threads

  1. Query to average between two dates.
    By stormchaser in forum Queries
    Replies: 4
    Last Post: 12-15-2011, 03:06 PM
  2. Average Query
    By Lorlai in forum Queries
    Replies: 3
    Last Post: 07-21-2011, 10:11 AM
  3. SQL query for average (2 tables)
    By JoshD in forum Queries
    Replies: 5
    Last Post: 04-13-2011, 06:12 AM
  4. Replies: 2
    Last Post: 07-14-2010, 06:10 AM
  5. Replies: 13
    Last Post: 05-28-2010, 11:57 AM

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