Query to Return Greatest Record

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
73,485
Office Version
  1. 365
Platform
  1. Windows
Given a table with three fields, Name, Date, and Amount, I want to write a query (in Access Query Builder or SQL, NOT in VBA) that will return the single record with the greatest value in the Amount field.

For example, if my data were:
Code:
NAME    DATE    AMOUNT
Adam   6/17/04   100
Bret   7/18/04   200
Cris   8/14/04    50
It would simply return:
Code:
Bret   7/18/04   200
It seems to me that this should be easy, and I may be having a brain cramp here.
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Maybe try this:

SELECT tblData.Name, tblData.Date, tblData.Amount
FROM tblData
WHERE (((tblData.Amount)=DMax("Amount","tblData")));


Does that give you what you need?
Mike.
 
Upvote 0
Yes, that does exactly what I want.

Thank you.
 
Upvote 0

Forum statistics

Threads
1,221,832
Messages
6,162,255
Members
451,757
Latest member
iours

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