Hi,
I can suggest you one way. This might not be a solution but you can try. I am sure there would be more such type of solutions.
If your data is in DataTable format then you can follow the following steps to get the required result.
1.) Import the DataTable to a database table (Temporary table).
2.) Once the data is imported to the table you can use the "Partition By" clause based on your data to be sorted out.
3.) Put a count in the query for the partitioned by column and get the last column reformed.
For references:
Partition By
Inserting a datatable to DB
Hope this will help you in achieving the goal. This is one of the way you can achieve your task. There may be many more.
Thanks,
Sisir Patro