Results 1 to 3 of 3
  1. #1
    MrBologna is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    48

    Filtering old Revisions out of a query

    I have a query that pulls a list of all assemblies & their parts from an ODBC database.
    The tables are formatted like this:

    Assemblies: AssemblyRecordNumber, Assembly_No, Assembly_Description


    BOMItems: RecordNumber, AssemblyRecordNo (joined with assemblies), RevisionNumber, ComponentRecordNumber (joined with parts database))

    So there is one record for each part for each assembly (quite a few records).

    It does its job pretty well, except for one special case:
    it does not differentiate between assembly revisions.

    So say I have assembly A, revision 0 with 10 parts.
    Then that assembly gets updated to have 5 parts (removed 5 of the parts from the assembly) and becomes revision 1.
    Right now, the query does not differentiate between the two revisions, and groups like rows to return 10 parts. Obviously I can turn off the grouping on revision, but I don't want to get 15 parts.

    Is there a good way to filter out everything except the rows with a maximum value in the revision number field, where the assembly number is the same?

    The only way I can think of right now is by creating a temp table of each assembly's current revision number each time I need to use this query and checking against that, but this is not a great solution because these tables are very large (lots of assemblies with lots of components each) and I would like to optimize as much as is easily possible.

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    join your query to another won that has the max version in it. Something like

    Q2:
    SELECT Assembly, max(revision) as maxRev
    FROM myTable
    GROUP BY Assembly

    your query simplified since I don't know what it looks like
    SELECT Assembly, Revision, PartNo
    FROM myTable

    your query incorporating Q2

    SELECT Assembly, Revision, PartNo
    FROM myTable INNER JOIN Q2 ON myTable.Assembly=Q2.Assembly AND myTable.Revision=Q2.MaxRev


  3. #3
    MrBologna is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    48
    Awesome, got it working and the second query is only a minor increase in run time. Thanks!

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

Similar Threads

  1. Help filtering query
    By nut75195 in forum Access
    Replies: 17
    Last Post: 02-11-2019, 05:47 PM
  2. Replies: 7
    Last Post: 03-23-2017, 10:26 AM
  3. Database for price offers and revisions
    By somabakr in forum Database Design
    Replies: 6
    Last Post: 12-30-2015, 04:56 PM
  4. Filtering a Query
    By Brian62 in forum Queries
    Replies: 2
    Last Post: 06-03-2010, 01:46 PM
  5. Filtering a Query
    By jbarrum in forum Access
    Replies: 1
    Last Post: 11-20-2009, 03:03 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