Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > using SUM in DataTable.Select()
 

using SUM in DataTable.Select()

Hi,

I have a "Orders" datatable that has marketID, OrderID and OrderSize in it.

I want to get SUM(ordersize) for each market or for a given market

Something like

SUM(order_size) group by market_id

or

SUM(order_size) where market_id = 19

I am not sure if the second statement is a valid one but I need something of this effect. Even groupby would work.

Now, How can I do this in

DataSet.DataTables[0].Select() ???

What kind of expression should I write in select method ??

I tried this

.Select("SUM(order_size) group by o.market_id ")

but got an exception

"An unhandled exception of type 'System.Data.SyntaxErrorException' occurred in system.data.dll

Additional information: Syntax error: Missing operand after 'group' operator."

What operand am I missisng here ??

Thanks,

bilalso  Wednesday, April 26, 2006 9:33 PM
I found it myself. I used .Compute()
bilalso  Thursday, April 27, 2006 1:27 PM
Use Datatable.Compute() method for summation a column value
objetc sumObject = _itemCheckData.Table.Compute("Sum(reco_price)", "");
sqzaman  Thursday, July 10, 2008 12:43 PM
Hi Friends,

I have addedsample codefor Datatable.Compute() in a post, kindly check the link

http://www.dotutorial.com/tutorial-tut1018-DataTable.Compute-Method.aspx


I think feature readers of this page will get use of this link
Visveswaraiah  Tuesday, September 01, 2009 6:26 PM

You can use google to search for other answers

Custom Search

More Threads

• How to Insert a vaule into a field?
• ExecuteScalar() in a windows form?
• Filling a typed dataset
• TableAdapter Configuration Wizard Update procedure parameters
• ArrayList to DataTable ...
• SqlDataSource/AccessDataSource in ASP.NET 2.0/VB-VWD 2005 Express: Can the filtered data be used in the derived variables?
• how to autogenerate date
• Datarow Compute Method / Object conversion error
• DatagridViewComboBoxColumn ValueMember and Custom Objects
• DataGridViewColumn.Visible=False is being ignored.