Results 1 to 9 of 9
  1. #1
    dmellman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    8

    Totaling and ranking results in queries

    Hello, All. This is my first post and I am using Access as a tool to link to data tables in a Pervasive database with ODBC, using queries and reports to extract and report molding press downtime and prioritize it. I am able to get the data with a query that selects rows of run data for each press and I can report that out.

    I have not figured out how to generate a report or query that totals records by press (but does not show them), and then ranks the presses by the totals in descending order. Example data:



    Press-AvailHrs-DownHrs-%DownTime*
    13-8-2-25
    13-8-1-12.5
    13-8-0-0 (Overall % Downtime 12.5)
    15-8-4-50
    15-8-3.5-44
    15-8-3-37.5 (Overall % Downtime 43.7)

    *(this is an query expression=DownHrs/AvailHrs)

    I want my report to list only two rows in descending order by Overall % Downtime, i.e.,

    Press-Overall % Downtime
    15-43.7
    13-12.5

    I was able to figure out how to make a ranking of descending
    %Downtime by cascading queries, but I can’t get past this point.

    I would greatly appreciate your help. (I searched the forum but could not find anything close.)

  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    well to start - the press overall avg doesn't involve the per day avg value - since one can not avg an avg so we work with this data:
    13-8-2
    13-8-1

    13-8-0
    15-8-4
    15-8-3.5
    15-8-3

    make a query that returns the data above - - and then modify it to be an Aggregate query (look that up in your textbook example - the epsilon E icon). And set the hours to be summed per press so you have this:

    13-24-3
    15-24-10.5

    the next step then is to use this query as the source for a new query that addes the calculated avg value you need:

    13-24-3-12.5
    15-24-10.5-43.75


    now you have a record source to use for a report - and do your ordering as part of the report feature....

    Hope it helps.

  3. #3
    dmellman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    8
    Thanks, NTC, for the fast reply. Yes, understood on averages of averages. So I tried earlier to do the epsilon function, which added the "Group by" line in my query. I set the AvailHrs and DownHrs columns to sum (did not touch the other columns) and when I ran the query, I got SumofAvailHrs and SumofDownhrs in each line of the query, but they only have the sums of each of those records, no aggregation (if that is correctly stated). Where does that come from?

  4. #4
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    can you post a sample database, I suspect you are using a GROUP BY field that is forcing your data to expand (for instance a shift number or primary key field) and removing that field will properly summarize your data.

  5. #5
    dmellman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    8
    OK. I tried a table with exactly that data and queried it, and it worked as you said it would, NTC, giving me the aggregated data.

    However, I looked at the original table and can see no primary key defined, and no other obvious things in the table structure that I can see. And it does not work the same way. So something is different about the table, I guess. What should I look for?

  6. #6
    dmellman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    8
    Here is the database (excerpted) with section of table and query that doesn't aggregate. Can you see what it is? Your assistance would be greatly appreciated.

  7. #7
    dmellman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    8

    Table won't aggregate

    Hi to all in the forum! I would greatly appreciate your help in understanding why the the query and table in the database I posted here (https://www.accessforums.net/queries...ies-15907.html) won't aggregate the way a simple table that I made does. I had tried to follow the suggestions of the posters in regard to that problem and found that my table and query were not aggregating. Can anyone shed some light on this?

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The query is aggregating. Field UDL5 has unique values. Including this field in the Group By makes every record unique. Including field SumDefects in Group By also impacts the aggregate calc. Remove these two fields from the query and aggregate calc will be at the UDL6 level - 3 summary records.
    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.

  9. #9
    dmellman is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    8
    Now I see, June7. Thank you and thank you, also, NTC and rpeare for help. I benefited from each of your suggestions. I think I will be able to finish now.

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

Similar Threads

  1. Ranking and assigning a Value
    By loopyl00 in forum Access
    Replies: 0
    Last Post: 01-11-2011, 12:14 PM
  2. Help to build a ranking
    By chorbi26 in forum Access
    Replies: 0
    Last Post: 12-20-2010, 12:47 PM
  3. Replies: 1
    Last Post: 07-10-2010, 09:56 PM
  4. Different results in queries
    By Vic in forum Programming
    Replies: 6
    Last Post: 11-06-2009, 10:58 AM
  5. Combine queries results in forms
    By frasilvio in forum Queries
    Replies: 12
    Last Post: 01-10-2008, 01:34 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