Filter DataTable to show only the most recent transaction for each user

Posted by Dan Neely on Stack Overflow See other posts from Stack Overflow or by Dan Neely
Published on 2010-03-17T14:51:08Z Indexed on 2010/03/17 15:21 UTC
Read the original article Hit count: 323

Filed under:
|
|
|

I have a datatable that contains rows of transaction data for multiple users. Each row includes UserID and UserTransactionID columns. What would I use for as a RowFilter in the tables DefaultView to only show the row for each user that has the highest UserTransactionID value?

sample data and results

UserID  UserTransactionID PassesFilter
1       1                 False
1       2                 False
1       3                 True
2       1                 True
3       1                 False
3       2                 True

My data is orginating in a non-SQL source, the DataTable is being created to be bound to a DataGridView so I can't make changes to a query being used to get the data initially.

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms