Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends ia have some rows ..student fee column

i wan to calculate by using student id how much fee was payed to school so please write a query for result for addition of rows values..

like student id =1 , his payed 3 time ,1000,500,3000..iwat to display total amount =4500 in asp.net so please help ..
thank you ,..
Posted

1 solution

You can use SUM function, returns the total sum of a numeric column. see below query snippet
SQL
SELECT SUM(fee) AS FeesPaid FROM table1 where student id =1 

Hope it helps
 
Share this answer
 
Comments
Member 10575434 2-Jan-16 4:29am    
i am write like this but it is not working
sqlcon.Open();
SqlCommand cmdac = new SqlCommand("select SUM[disamount] from tbl_sjodata where svid=@visionid", sqlcon);
cmdac.Parameters.AddWithValue("@visionid",lbl_visionid.Text);
int ac = Convert.ToInt32(cmdac.ExecuteScalar());
lbl_availablecreditamount.Text = Convert.ToString(ac);
sqlcon.Close();
koolprasad2003 2-Jan-16 4:48am    
First just try to run plain query in SQL Query Analyzer and see if it produce output and then try for the code, let me know if it really works

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