Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello ,
I am recieving some data from the service . It's in this format

WareHouse   WareHouseType    Type     

AAA             1             11
AAA             1             12
AAA             1             13
AAA             1             12
BBB             1             11
AAA             1             12
AAA             1             12
BBB             1             11
BBB             1             12    


Now i need result in this format

warehouse      WareHouseType    Type   Count
AAA               1              11     1
AAA               1              12     4
AAA               1              13     1
BBB               1              11     2
BBB               1              12     1  


any suggestion how to achive this ?? I tried search about grouping inside datatable but no luck..
Posted
Updated 23-Sep-15 2:03am
v2
Comments
[no name] 23-Sep-15 8:07am    
In which format you are getting the result from the service? in which container you are keeping this?
Riya-Pandey 23-Sep-15 8:10am    
I am inserting this data into a datatable.
[no name] 23-Sep-15 8:21am    
Please see my solution. If you have any query let me know.

1 solution

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
 
Share this answer
 
Comments
aarif moh shaikh 23-Sep-15 9:01am    
agree with you...
[no name] 23-Sep-15 9:05am    
Cool. Try this solution until and unless you get a better solution.

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