Click here to Skip to main content
15,908,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,
I working on a web application, I am using a data table that can contain record like :

|MedicineID|| Quantity |
| 1 || 5 |
| 2 || 10 |
| 2 || 5 |
| 1 || 4 |
| 3 || 8 |

Please help me how could I perform group by on this table bases of MedicineID and count total Quantity of MedicineID

Thank You
Rahul

What I have tried:

how to perform Group By operation on Datatable in ASP.net Using C#
Posted

you try this

select sum(Quantity) from your table name group by medicineid
 
Share this answer
 
Comments
Rahul Newara 9-Feb-16 5:52am    
Thank U
Hi You can use

C#
dt = dt.Select("SELECT SUM(Quantity), MedicineID GROUP BY MedicineID);


this will help you
 
Share this answer
 
Comments
Rahul Newara 9-Feb-16 5:52am    
Thank U
 
Share this answer
 
Comments
Rahul Newara 9-Feb-16 5:52am    
Thank U

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