Click here to Skip to main content
15,868,141 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello programmers,

Got a problem here. As you can see I manipulate all the data in a tables. but first here are my field names; name, category, amount, size. Now when I manipulate the database, say:
NAME CATEGORY AMOUNT SIZE
         man  banana    12    7          and
         girl  ball     30    2

That will be the look in the database.
My question is that, can I add all the numbers say on amount; all the numbers in amount will be added.

thanks and more power
Posted
Updated 25-May-11 23:07pm
v2
Comments
Ashishmau 26-May-11 1:56am    
First,Learn Basics of Sql

1 solution

Very simple SQL code to do this:

select sum(Amount) as TotalAmount from TABLENAME
 
Share this answer
 
Comments
janwel 26-May-11 1:57am    
sir is it posible that when i manipulate a data the sum(i think i will put to label) will be auto calculate?
_Damian S_ 26-May-11 1:58am    
Every time you run an SQL statement on a table, it is calculated at that point in time, so if you run it now, then change your data and then run it again, the value will change.
janwel 26-May-11 2:05am    
ok sir thanks
janwel 26-May-11 2:07am    
sir "as TotalAmount" means?
lbl.Text = (DataReader("TotalAmount").ToString) is this correct?
_Damian S_ 26-May-11 2:23am    
as TotalAmount means give the field name TotalAmount, so if your have it in your query, your DataReader line should work.

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