Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,


in my application i wanted to store donor details ,so i have created a donor table with some field like donor name, amount etc.. same donor can donate amounts any time. so i wanted to get the total amounts donated by each donors is there any way?

Thanks
Ginnas
Posted
Updated 27-Mar-13 21:55pm
v2

You need the SUM function and a GROUP BY clause.
Something like
SQL
SELECT donor, SUM(donation) as TotalAmount
From MyTable
Group By donor
 
Share this answer
 
Comments
ginnas 28-Mar-13 5:25am    
Thanks Hiller
it helped me truely, thank you very much
i have few more doubts,in the same table i have to get 1-the donors who donating more than 10000 in year
2-donors who are not donating during the past 2 years
in my table i have one field for storing the donating date

so how can we do this ?

Regards
Ginnas
Well, you need to use the aggregate function to get the total amount.
And you need to use the Group by clause to group the total amount from each donor.

SQL
select donor, sum(amount) from tbl_x group by donor


that's all.
I hope this helps you.
 
Share this answer
 

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