Results 1 to 3 of 3
  1. #1
    ohthesilhouettes is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    7

    Help with Dmin function

    Hi I have data about treaty names for a given country for a given year and for a given action.



    TreatyName Country Year Action
    Treaty A USA 1979 Signed
    Treaty A USA 1985 Ratified
    Treaty A France 1990 Signed
    Treaty B USA 2000 Signed
    Treaty B USA 2001 Ratified

    *I want to treat Action as the same and I want a query to send me back the earliest year of a treaty for a country (this is where Dmin comes in)

    The new table should look like this:

    Treaty A USA 1979 Signed
    Treaty A France 1990 Signed
    Treaty B USA 2000 Signed

    I am having trouble with getting Dmin to work on multiple fields.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,537
    Hi
    Code:
     
    SELECT YourTableName.TreatyName, YourTableName.Country, Min(YourTableName.Year) AS MinOfYear, YourTableName.Action
    FROM YourTableName
    GROUP BY YourTableName.TreatyName, YourTableName.Country, YourTableName.Action
    HAVING (((YourTableName.Action)="Signed"))
    ORDER BY Min(YourTableName.Year);
    This gives the results you were looking for.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    ohthesilhouettes is offline Novice
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Posts
    7
    Thanks so much it really helped!

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

Similar Threads

  1. if function
    By lolo in forum Queries
    Replies: 1
    Last Post: 08-01-2010, 11:38 PM
  2. Want function to get current function name
    By Davis DeBard in forum Programming
    Replies: 2
    Last Post: 08-13-2009, 05:02 AM
  3. Sum Function Help
    By newbie in forum Reports
    Replies: 3
    Last Post: 06-30-2009, 05:32 PM
  4. Avg Function
    By hiker8117 in forum Access
    Replies: 3
    Last Post: 04-23-2009, 11:14 PM
  5. Is there a function to do this....
    By Nowherefast in forum Access
    Replies: 2
    Last Post: 12-31-2008, 08:08 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