Get larger of two values in a query ACCESS 2010

I have a table in an ACCESS 2010 that is only sample data.  However, a user duplicated over 6000 rows but the dollar amounts are different.  So, how do I extract only the larger of say, December amounts for duplicate rows of the same forecast year, account number and type.  That is, for 2010, AcctNo 14587, BUD that has two rows, but December is 100 for one row and 150 for the second row - I need  only get the 150 row.

Sandra SmithRetiredAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Boyd (HiTechCoach) Trimmell, Microsoft Access MVPDesigner and DeveloperCommented:
I would use a sub query.

See: Subquery basics

Delete duplicate records

This example uses a subquery to de-duplicate a table. "Duplicate" is defined as records that have the same values in Surname and FirstName. We keep the one that has the lowest primary key value (field ID.)
WHERE ID <>  (SELECT Min(ID) AS MinOfID FROM Table1 AS Dupe      
   WHERE (Dupe.Surname = Table1.Surname)                         
   AND (Dupe.FirstName = Table1.FirstName)); 

Open in new window


Nulls don't match each other, so if you want to treat pairs of Nulls as duplicates, use this approach:

WHERE ID <>  (SELECT Min(ID) AS MinOfID FROM Table1 AS Dupe      
   WHERE ((Dupe.Surname = Table1.Surname)                        
     OR (Dupe.Surname Is Null AND Table1.Surname Is Null))       
   AND ((Dupe.FirstName = Table1.FirstName)                      
     OR (Dupe.FirstName Is Null AND Table1.FirstName Is Null))); 

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Kent DyerIT Security Analyst SeniorCommented:
Some pseudocode..

select A.SalesValue, B.RevenueValue,
Case when Sum(A,SalesValue) > Sum(B.RevenueValue) Echo B.SalesValue is bigger than A.RevenueValue End
Case when Sum(B,SalesValue) > Sum(A.RevenueValue) Echo B.SalesValue is bigger than A.RevenueValue End
From SomeTable
Left Outer Join A.Emp_id - B.Emp_id

Open in new window


Sandra SmithRetiredAuthor Commented:
Sorry it took me so long.  I lost my job and have been in a state of shock.  This did resolve the issue.  Sandra
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Applications

From novice to tech pro — start learning today.