Click here to Skip to main content
16,020,666 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi every body
how to select last record for each user Ms acess 2013 for example i have data like

1  : 20    : 1/4/2015<br />
1 : 25     : 10/4/2015<br />
1  : 30    :  15/4/2015<br />
2  : 10  :  1/5/2015<br />
2  :15     :5/5/2015<br />
2  :20    :  20/5/2015<br />
3  :5     :1/6/2015<br />
3  :10    : 10/5/2015


how can i get last row for each user as a result

1  : 30    :  15/4/2015<br />
2  :20    :  20/5/2015<br />
3  :10    : 10/5/2015


i try top, max but it was useless how it can be achieved
Posted
Comments
CHill60 15-Jun-15 19:06pm    
what do you mean "it was useless"? Post the query you tried and we can help you correct it
PIEBALDconsult 15-Jun-15 20:17pm    
Create a better schema that supports that easily.

1 solution

Please find the logic for MSSQL below.
Change it in for MS - Access as per your requirement.
Considering your list as
"Id : UserId : ModifiedDate"


SQL
;with cteRowNumber as (
    select * , row_number() over(partition by Id order by ModifiedDate desc) as RowNum
        from YourTable
)
select *
    from cteRowNumber
    where RowNum = 1
 
Share this answer
 
Comments
ost3z 16-Jun-15 8:22am    
it doesn't work in ms access

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900