access query with duplicates data

touchmove

New Member
Joined
May 18, 2015
Messages
10
Hi to everyone!

Below is my data:
DetailDrawingNoRevisionNoAdvance CopyOfficial SubmittalDate CommentedStatusATTACHMENTS
4KAP2C1-35-AR-0400-DD-010004/20/20155/1/20155/14/2015Revise and Resubmit0
5KAP2C1-35-AR-0400-DD-01001
5/21/20155/27/2015Approved As Noted0
6KAP2C1-35-AR-0400-DD-01002
6/1/20156/7/2015Approved0

<caption> REVIEW CYCLE </caption><thead>
</thead><tbody>
</tbody><tfoot></tfoot>

As you can see, there is duplicates in DrawingNo column. I want to create a query which would get only the DrawingNo with the latest RevisionNo which is RevisionNo 2.


Can someone help me with the code?

Appreciate your quick reply.


More powers!
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Create a query and add your fields then select the Totals Icon this should Group things, change the group for the Revision Number to Max that should give you what you need.
 
Upvote 0

DrawingNoMaxOfRevisionNoAdvance CopyOfficial SubmittalDate CommentedStatusATTACHMENTS
KAP2C1-35-AR-0400-DD-01001
5/21/20155/27/2015Approved As Noted0
KAP2C1-35-AR-0400-DD-01002
6/1/20156/7/2015Approved0
KAP2C1-35-AR-0400-DD-010004/20/20155/1/20155/14/2015Revise and Resubmit0

<caption> REVIEW CYCLE Query </caption><thead>
</thead><tbody>
</tbody><tfoot></tfoot>


Trevor,

Above table is the result after following your procedure. How can I display only DrawingNo with the latest revision?
 
Upvote 0
You can do this in a set of two queries.

First, create a query called "LatestRevision".
Do this by adding the table to the query, and adding only the "DrawingNo" and "RevisionNo" fields to the query (but NO other fields).
Then, click on the Totals button.
Under the "DrawingNo" field, leave the Totals row setting to "Group By", but under the "RevisionNo" field, change the value to "Max".
If you view the results, it will show you the latest RevisionNo for each DrawingNo.

Now, if you want to get all of the other field values, create a new query linking the ""LatestRevision" query you just made to your original table on BOTH fields in your query.
Then, select all of the fields you would like to return from the original table.

This should give you what you want.
 
Upvote 0

Forum statistics

Threads
1,215,454
Messages
6,124,933
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top