How to calculate sum of database column in sql

I have database column "Marks" in my database. Now i want to count the sum of these column.. how to achieve this task.. Any help would be appreciated.
Posted by Prince Mahajan 3/22/2014 10:49:28 PM
Total Answers : 2
Answer 1
Your Sql Query will be like :
select SUM(Marks) as Total_Marks from table1
In C# it will be like :
SqlCommand cm = new SqlCommand("select SUM(Marks) as Total_Marks from table1", cn);

Let me know if this helped you.
Posted by StepCoder Team 3/24/2014 5:18:01 PM
Answer 2
You can use the sum function for calculation. Suppose if you want to calculate the sum of all the column, you just have to do this : Sum(column_name).
Your sql query will be like :
select sum(column_name) as sum_of_column from table_name.
Posted by Andrew Dvorkin 3/26/2014 3:44:57 PM
Post your answer
Sign in to your account
Your Email : 
Password :   
Forgot your password
Don't have StepCoder account ?
Create a new account
Follow me on twitter
About Me
Harpreet Singh
I began programming with C++ when i was 17. Then at the middle of my study .NET came. Then I began to read C# and VB.NET. By the time i learnt SQL and ASP.NET, and developed some websites such as news portals that are active now. Currently i am running my own Software company.
Answer these questions! If you know the answer.