Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2012
    Posts
    2

    Selecting only one record for a max of in a design query


    Hi there, hope someone can help..

    I want to select only one record when using a max of aggregation. e.g. if I have year, item, price and I want to find the most recent price of every item my instinct is to the aggregation to MaxOfYear and GroupByItem but I can't do anything with price. If I use GroupBy it will give me a new record for every change in price so I won't get a unique one record per item result. In theory I would want an option called something like 'passive' so it just gives me which ever record obeys the instructions of the other two aggregations, but this doesn't exist. It seems so simple i feel i must be missing something. I hope this makes sense. I am only working in design mode.


    Many thanks

    Phil

  2. #2
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Assuming,
    The Item & The Year together are unique in your table (myTable),
    try joining
    the aggregate query that you have described
    to your same Table (myTable)
    with
    the join on, perhaps something like below :

    SELECT
    ..............
    FROM
    qry
    INNER JOIN
    myTable
    ON
    (qry.MaxOfTheYear = myTable.TheYear)
    AND
    (qry.TheItem = myTable.TheItem)

    Just see if it works.

    Thanks

  3. #3
    Join Date
    Aug 2012
    Posts
    2
    thanks recyan,

    I just about understood what you meant. (I am in design mode not SQL). I've tried it and it works, so job done.

    thanks again

    phil

  4. #4
    recyan's Avatar
    recyan is offline Expert
    Windows 2K Access 2000
    Join Date
    Dec 2011
    Posts
    662
    Glad you found it helpful.

    Thanks

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

Similar Threads

  1. Selecting a Record in Datasheet view
    By JFo in forum Access
    Replies: 3
    Last Post: 11-01-2011, 10:10 PM
  2. Replies: 9
    Last Post: 09-16-2011, 03:52 PM
  3. Record Selecting
    By dbprogman in forum Programming
    Replies: 5
    Last Post: 04-27-2011, 10:35 PM
  4. Replies: 5
    Last Post: 12-06-2010, 09:29 AM
  5. Help with Selecting a single record in access.
    By rfhall50 in forum Programming
    Replies: 3
    Last Post: 08-10-2009, 08:50 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