Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find the last current record in a table

Status
Not open for further replies.

04061975

Programmer
Mar 19, 2003
8
AU
I have a table of data that has a date and qty field. For each month there will be 4 entries (one for each week). How can you select or display the last entry of each month?
 
Hi,

Why don't you add a Week No field to the Table, then you could create a query which only displays the Week 4's?

I'd be happy to offer further advice if you could elaborate on what you require,

Regards,


Trystan
 
I think you could also do this with IN and an aggregate
subquery, like so:

SELECT *
FROM YourTable
WHERE YourTable.[date]
IN (SELECT max([date]) FROM YourTable
GROUP BY month([date]));

This should return all fields from the last entry for
each month.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top