Click here to Skip to main content
15,915,632 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends I need to group the elements of GridView as shown below.
I need to sum up the price according to its ID's

Data in GridView

ID1-----ID2-----Price
----------------------
1-------1-------100
2-------1-------200
3-------1-------150
4-------2-------120
5-------2-------160
6-------3-------100
7-------3-------200

I want to group this data as shown below and save it in a datatable so that I can pass it to my Database

ID2-----Price
-------------
1-------450
2-------270
3-------300

How do I do this?
Thanks in advance
Posted
Updated 10-Feb-14 19:12pm
v2

1 solution

Select ID2, SUM(Price) from table_name group by ID2 asc
 
Share this answer
 

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