Results 1 to 3 of 3
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    Find the max value (not as simple as it sounds)

    Ok so I have a query that has 3 fields: Package, Package Component, and Retail Price of that package component.

    I am trying to do a group by that yeilds 1 record for each package, has the most expensive component, and the price of that component.
    Click image for larger version. 

Name:	expens.jpg 
Views:	10 
Size:	49.1 KB 
ID:	13894
    I sorted the query by package (ascending), and price (descending).

    I built a query on top of that one, and did a group by on package, first on component, and first on retail price.



    I do not get the value that I should.

    I am kind of stumped on this what seems like a very simple query to make.

    Any thoughts or suggestions?

    EDIT: I am doing this on a remote server, so I am on Access 2003, not 2010.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    There are a few ways to do this.

    One way is to use two queries.

    First Query
    Create an Aggregate Query that only has two fields, Package and Price.
    Group by Package, and return the Max Price value.
    This will return the maximum Price for each Package.

    Second Query
    Link your first query back to your original table on both the Package and Price fields.
    Return all three fields from your original table.
    This should give you what you want.

    Note that you can also do all this in a single query, if you use subqueries or nested queries.

  3. #3
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Wow. I tried this and linked only the price field and it gave me all sorts of wacky results. Didn't think about linking both fields.

    Thank you so much!

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

Similar Threads

  1. Replies: 0
    Last Post: 10-21-2010, 08:24 AM
  2. Simple Export Not So Simple
    By jgelpi16 in forum Programming
    Replies: 11
    Last Post: 09-01-2010, 07:23 AM
  3. Play sounds and Common Dialog Box example
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 08-29-2010, 06:49 AM
  4. relative path to sounds... strange
    By ymds in forum Programming
    Replies: 3
    Last Post: 07-14-2010, 03:05 PM
  5. databasing CDs, sounds easy right?
    By RAGEFEAR in forum Access
    Replies: 8
    Last Post: 06-02-2009, 04:15 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