Joe4
MrExcel MVP, Junior Admin
- Joined
- Aug 1, 2002
- Messages
- 74,188
- Office Version
- 365
- Platform
- Windows
Is there a simple way to do the following in one, succint SQL query? I know I can do it by breaking it up into two queries, but would like to get it down to one (hopefully simply) query.
Here is my table structure:
*Company ID
*Person_ID
Change_Date
Value
(there are other fields, but they are not important to the query, or part of the result set).
Here is what I would like to do:
For each Company_ID/Person_ID combination, I would like to return only the most recent record (based on Change_Date) and display the Value associated with that record.
For example, if I had:
It would return:
Thanks!
Here is my table structure:
*Company ID
*Person_ID
Change_Date
Value
(there are other fields, but they are not important to the query, or part of the result set).
Here is what I would like to do:
For each Company_ID/Person_ID combination, I would like to return only the most recent record (based on Change_Date) and display the Value associated with that record.
For example, if I had:
Code:
123456789,111111111,07/01/2006,B
123456789,111111111,07/02/2006,C
123456789,111111111,06/30/2006,A
123456789,222222222,06/29/2006,A
Code:
123456789,111111111,07/02/2006,C
123456789,222222222,06/29/2006,A