Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get sum of a column called "PaidAmount" from PaymentMaster table, which has UserId field, In that one user may have many records, Now I want the sum of Total PaidAmount of each user. So Can anyone help me please?


I tried like this

SQL
select Sum(PaidAmount) from PaymentMaster

select Sum(PaidAmount) from PaymentMaster where UserId=@UserId


But here in first query I'm getting total paid amount of all users, and in second query i've to pass each userId.



Thanks in @dv@nce :P
Posted

1 solution

Try:
SQL
SELECT UserID, SUM(PaidAmount) AS Total FROM PaymentMaster GROUP BY UserId
 
Share this answer
 
Comments
Aboobakkar Siddeq D U 20-Aug-13 1:36am    
Thanks a lot
OriginalGriff 20-Aug-13 1:39am    
You're welcome!

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