Link to home
Start Free TrialLog in
Avatar of softsupport
softsupportFlag for United States of America

asked on

How in access 2007 can I hide or exclude a row of data in my query

I designed a query to list data for a client for each month [claimdate].  A client may have  multiple rows of data for the same [claimdate],  however, I only want to list the [claimdate] with the largest revision number.  

I have attached a spreadsheet depicting the information listed above.  From my query,  I highlighted two rows of data, with the same [claimdate] (10-31-2013).   I only want to display or list the [claimdate] with the newest/greatest [RevisionNo].... in this example would be 1, however,  client can have several revisions (2, 3, etc. )  

FYI, a client can have multiple months with duplicate [claimdate] not shown in this example.
Your assistance is always greatly appreciated.
Query-Exclusion.xlsx
Avatar of magarity
magarity

Unfortunately Access does not have a built in RANK function but your query is simple enough to do it yourself like this:

First, make your own ranking query
SELECT CLAIMDATE, REVISIONNO, (SELECT COUNT(*) FROM table B WHERE A.CLAIMDATE = B.CLAIMDATE AND B.REVISIONNO > A.REVISIONNO) AS REV_RANK FROM table A

From that, you can select where REV_RANK is 1.  I may have assumed incorrectly somewhere in the details of my example query, but this should get you going in the right direction.
Avatar of PatHartman
Although you can do this with a sub query, I prefer separate queries that I join since that gives me the ability to test them independently.
qry1 - Select ClientID, ClaimDT, Max(RevisionNo)
From YourTable
Group By ClientID, ClaimDT;

Second query join qry1 to the query you are currently using to limit the resultset to only the most recent revision for each claim.
Avatar of softsupport

ASKER

Please explain where to place this in my query.
Who are you addressing?  What does your query look like now?
I am sorry Pat.... I was trying your solution.

Please see attached.
query.docx
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That should have been simple, but drove me crazy.  Thank you so very much.
I have another question regarding access ID: 28485671.  Can you assist with this as well.  Separate issue.