This is giving me fits. In a membership listing, each member could have
many transactions (one to many relationship). I want to retrieve each member
ID, and their corresponding most recent (MAX) transactionID. The memberID
joins the two tables.
I've tried several ways without success. The statement below below returns
ALL the transaction records for any given individual member, not just the
most recent transactionID. What am I doing wrong?
SELECT M.firstName, M.middleName, M.lastName, M.email, M.company, M.city,
M.zip, M.memberID, M.memberLevelID
FROM #REQUEST.prefix#_Members_List M
WHERE M.memberID =
(SELECT MAX(T.transactionID) AS transactionID, T.paidThru,
T.transactionDate, T.memberID)
FROM #REQUEST.prefix#_Members_TransactionLog T
WHERE T.memberID = M.memberID) AND
...more filters ...
GROUP BY M.memberID, M.firstName, M.middleName, M.lastName, M.email,
M.company, M.city, M.zip, M.memberLevelID, T.paidThru, T.transactionDate,
T.memberID
ORDER BY M.lastName
[Todays Threads]
[This Message]
[Subscription]
[Fast Unsubscribe]
[User Settings]
[Donations and Support]
- Best practices storing CC Don Vawter
- RE: Best practices storing CC Rick Osborne [Mojo]
- Re: Best practices storing CC Alex
- Re: Best practices storing CC BILLY CRAVENS
- RE: Best practices storing CC Zac Belado
- Re: Best practices storing CC BILLY CRAVENS
- Re: Best practices storing CC Don Vawter
- Re: SQL-Server DTS through CF William H. Bowen
- Re: Best practices storing CC Jim McAtee
- Re: Best practices storing CC BILLY CRAVENS
- Re: SQL Query problem Mark Leder
- Re: SQL Query problem Alexander Sherwood
- RE: SQL Query problem Mark Leder
- RE: SQL Query problem Alexander Sherwood
- RE: SQL Query problem Mark Leder
- RE: SQL Query problem Alexander Sherwood
- RE: SQL Query problem Mark Leder
- RE: SQL Query problem Alexander Sherwood
- RE: SQL Query problem Mark Leder
- Re: SQL Query problem Marc Lowe
- RE: SQL Query problem Mark Leder