I am creating a Smart Client application using the SQL Server Compact Edition. The compact edition does not support the top clause. I need to recreated the functionality of the query listed below without using the top clause, because it is not supported in CE. The query below returns the Address information for the most recent Address of customers attending a meeting. The customer can have multiple current addresses, so the most recent one is the one with the latest DateCreated. I'm guessing I can do this with the MAX aggregate function, but I haven't been able to figure it out.
Code:
SELECT Customer.CustID, Customer.Prefix, Customer.FName, Customer.MName, Customer.LName, Customer.Suffix, Organizations.OrgName,
a.Com, a.Email, CustMeetingsID
FROM Addresses AS a INNER JOIN
Customer ON a.CustID = Customer.CustID INNER JOIN
Organizations ON a.OrgID = Organizations.OrgID INNER JOIN
CustMeetings ON Customer.CustID = CustMeetings.CustID
WHERE (a.AddressID IN
(SELECT TOP (1) AddressID
FROM Addresses AS b
WHERE (a.CustID = CustID) AND (CurrentAddress = 1)
ORDER BY DateCreated DESC)) AND (CustMeetings.MeetingID = @MeetingID)
ORDER BY Customer.LName, Customer.FName, Customer.MName, Organizations.OrgName