finding the most recent date

dsundy2003

New Member
Joined
Dec 26, 2002
Messages
40
Hi there

I have a table with 2 fields, and say 3 rows (to keep it simple)

Customet No. Date
-------------- ------
001 1/1/2003
002 30/12/2003
003 15/7/2003

How do I write a query to retrn the customer No and the date for the largest date. In the above example, it will return 002 and 30/12/2003. I tried using the MAX function on the 'Date' field, but it doesnt work.
I have a more complicated query with more variables, but this step is holding me back.

Pls advise

Darryn
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Can you post up the SQL code ?

I have something similar that gets a groupid and "latest record date" using MAX and it works fine..

Heres my SQL - see if it helps

Code:
SELECT dbo_grup.id, Max(dbo_gchg.effective) AS MaxOfeffective
FROM dbo_grup INNER JOIN dbo_gchg ON dbo_grup.rowno = dbo_gchg.rowno_grupgchg_grup
WHERE (((dbo_grup.id)=[dbo_gchg].[id]))
GROUP BY dbo_grup.id;

To view, got view SQL View

Hope this helps
 
Upvote 0

Forum statistics

Threads
1,221,539
Messages
6,160,412
Members
451,644
Latest member
hglymph

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