I have a table similar to this one CancelLog
|ID| membrecia| User | DateCancel | Motivo |
| 2| 1 | uS1 | 7/29/2011 | ... |
| 3| 1 | uS2 | 7/30/2011 | ... |
| 6| 1 | uS1 | 8/02/2011 | ... |
| 1| 2 | uS1 | 7/28/2011 | ... |
| 4| 2 | uS2 | 7/30/2011 | .... |
| 5| 2 | uS3 | 8/01/2011 | . |
| 6| 3 | uS1 | 8/02/2011 | . |
and I would like to get the most recent record of each membership is to say something like this
|ID| membrecia| User | DateCancel | Motivo |
| 6| 1 | uS1 | 8/02/2011 | ... |
| 5| 2 | uS3 | 8/01/2011 | . |
| 6| 3 | uS1 | 8/02/2011 | . |
I was doing something similar to this,
select l.membrecia, l.[USER] , l.DateCancel, count(*), max(l.DateCancel)
from CancelLog l
group by l.membrecia, l.[USER], l.DateCancel;
count(*) y max(l.DateCancel)
only use them as news, they will not be in the final consultation
If you throw me the most recent results, but if a membership is "canceled" * by several different users, it brings me the data of all users who canceled it
|ID| membrecia| User | DateCancel | Motivo |
| 3| 1 | uS2 | 7/30/2011 | ... |
| 6| 1 | uS1 | 8/02/2011 | ... |
| 1| 2 | uS1 | 7/28/2011 | ... |
| 4| 2 | uS2 | 7/30/2011 | .... |
| 5| 2 | uS3 | 8/01/2011 | . |
I would like to obtain the records like those shown in table 2.
* During the cancellation, the "Reason" can be changed, and due to this change is that a new record is created in the log.
change from motivo
"Temporary low" to "Definitive low", so I am interested only in the last change regardless of the user, but I do need the last user who made the change in the results.
Someone knows how you could get those records