Hi All.
I've trying to select the first 2 clients from each household. I'm sort of close but I can't see where to go from here.
The following code selects those households that have less than 3 clients in them. I'd like to select every household and also up to 2 clients belonging to that household.
SELECT h.RecordID, [Adults]+[Children] AS Total, c.FirstName, c.LastName, h.Street, h.Address, h.Suite
FROM tblHouseholds AS h INNER JOIN tblClients AS c ON c.RecordID = h.RecordID
WHERE ( SELECT COUNT(*)
FROM tblClients
WHERE RecordID = c.RecordID ) < 3
ORDER BY h.RecordID;
Thanks for any help.
Rick
--
I've trying to select the first 2 clients from each household. I'm sort of close but I can't see where to go from here.
The following code selects those households that have less than 3 clients in them. I'd like to select every household and also up to 2 clients belonging to that household.
SELECT h.RecordID, [Adults]+[Children] AS Total, c.FirstName, c.LastName, h.Street, h.Address, h.Suite
FROM tblHouseholds AS h INNER JOIN tblClients AS c ON c.RecordID = h.RecordID
WHERE ( SELECT COUNT(*)
FROM tblClients
WHERE RecordID = c.RecordID ) < 3
ORDER BY h.RecordID;
Thanks for any help.
Rick
--