Results 1 to 3 of 3
  1. #1
    LilMissAttack is offline Novice
    Windows XP Access 2007
    Join Date
    May 2010
    Posts
    26

    Group By / MAX Function


    I thought I was headed in the right direction with this but can't quite figure it out.

    I have 3 tables. One is a list of all manufactured items. The 2nd table lists all the components for those manufactured items. For instance, a manufactured item could simply be it's own item, or could be made up of several components..sometimes 10 or more. In the 3rd table, I have the lead time of each of those components.

    I want to pull the list of manufactured items and the component with the longest lead time for each manufactured item. Then I would like it to pull the 2nd longest lead time. Is this best done with grouping and the Max function?

    Thanks!

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    You can Group By [ManufacturedItem] and Order By [LeadTime] Desc . . .

    That should give you what you need - if I understand your requirement correctly.

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Are you looking at only pulling the two longest lead times for each manufactured item or are you looking to sort the entire list of components from largest lead time to lowest lead time?

    If it's the latter you can follow robeen's suggestion

    If it's the former, create robeen's query and where it says SELECT in the sql statement of your query type in SELECT TOP 2 and it will show you only the two longest lead time items for a specific assembly.

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

Similar Threads

  1. query group by over another group by?
    By gap in forum Queries
    Replies: 2
    Last Post: 07-04-2011, 12:59 AM
  2. Replies: 0
    Last Post: 04-25-2011, 07:58 PM
  3. Group By Function on a Form
    By amcalabrese in forum Access
    Replies: 0
    Last Post: 03-26-2011, 08:45 AM
  4. Replies: 5
    Last Post: 11-29-2010, 08:16 AM
  5. columns for group detail but not group header?
    By Coolpapabell in forum Reports
    Replies: 0
    Last Post: 08-21-2009, 08:53 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