Results 1 to 5 of 5
  1. #1
    nggman is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    27

    Top 4 multiple groups

    I have an Access query where I am pulling multiple drug type groups with an amount. I need to be able to only pull the top 2 dollar amounts for each group.
    Is there a way to do this? Thanks!!

    Ex.

    Emergency Meds $4.00
    HIV $5.00
    Psychotropics $5.55
    Topical $10.00
    Analgesics $3.78
    Emergency Meds $23.95


    Vaccines $26.88
    Cardiac $34.44
    Emergency Meds $1.23
    HIV $5.22
    Topical $1.22
    HIV $3.44
    Topical $45.44

    I am not going to put in more examples because I do not want my sampling to be too large. I only need to pull the top 2 dollar amounts for each group:


    Emergency Meds $23.95
    Emergency Meds $4.00
    HIV $5.22
    HIV $5.00
    Topical $45.44
    Topical $10.00

    etc, etc

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    nggman is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    27
    No. I have tried that syntax and it did not work for me.

  4. #4
    nggman is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Oct 2017
    Posts
    27
    I found this and it worked. Thanks.

    selecttype, variety, pricefrom fruitswhere ( selectcount(*) from fruits as f where f.type = fruits.type and f.price >= fruits.price) <= 2;

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Glad you found something that worked.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 6
    Last Post: 04-04-2017, 10:47 AM
  2. Replies: 3
    Last Post: 12-14-2016, 03:14 AM
  3. Replies: 3
    Last Post: 10-15-2013, 10:54 AM
  4. Creating groups based on multiple values
    By cardgage in forum Queries
    Replies: 2
    Last Post: 03-28-2013, 08:29 AM
  5. Replies: 2
    Last Post: 06-27-2012, 05:02 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