Thursday, February 16, 2012

Adding data from fields to get a total

EX: I have a table for products, and each product has a quantity. How can I add up the QTY field in all the rows to find out the total QTY of all the products.

Any help would be greatly appreciated.

gkc

You don't say whether you're using a GridView or DataGrid (or anything in particular) -

I'm hoping you're using ASP.Net 2.0 and can use the GridView - because this code sample from ASPNet101.com shows how to create a calculated column - not the exact column you want, but the code's the same :
http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=GVFooterTotal

|||Thank you for the help!

Actually, I am not using any controls. I know there must be a way to do this in TSQL, I am just not familiar with it.|||check out the SUM function in SQL.|||Yes! That was exactly what I needed.

Thank you!

No comments:

Post a Comment