I have to create a query that compiles a bunch of data for each player (user) from multiple tables. For instance, I have two tables: tblMembers and Off_Ice_Testing.
There are multiple off_ice_testing for each tblMembers (or none). How do I select one off_ice_testing that has the latest date?
I tried:
SELECT m.LastName,
m.FirstName,
office.Date AS [off ice date]
FROM tblMembers AS m
LEFT JOIN (SELECT Date, UserID
FROM Off_Ice_Testing) AS office ON m.UserID = office.UserID
WHERE m.LastName LIKE '%player%'
But that gets back a record for each Off_ice_Testing. If I do Top(1) in the derived table, that won’t work. I feel like I should know this, but I’m stuck. And for future reference, what would you call this type of query?
1 Answer