View Single Post
  #5  
Old June 2nd, 2010, 12:13 AM posted to microsoft.public.access.forms
KenSheridan via AccessMonster.com
external usenet poster
 
Posts: 1,610
Default Picking only the latest entry?

You can restrict the query by means of a subquery which returns the latest
(MAX) date per property/bill, e.g.

SELECT Property, Bill, BillDate, Amount
FROM Properties INNER JOIN Expenses AS E1
ON Properties.PropertyID = E1.PropertyID
WHERE BillDate =
(SELECT MAX(Billdate)
FROM Expenses AS E2
WHERE E2.PropertyID = E1.PropertyID
AND E2.Bill =E1.Bill)
ORDER BY Property, Bill;

The two instances of the Expenses table are differentiated by the aliases E1
and E2, enabling the subquery to be correlated with the outer query.

Ken Sheridan
Stafford, England

Pascoe wrote:
Bumping this back up!

Hoping for a reply!

Jeff,

[quoted text clipped - 11 lines]
Kind Regards,
Russell.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...forms/201006/1