1

I have two tables Loan and Member. Now in Loan i have column totalamount and in Member i have column as membertype and in Loan i have various loan according to membertype. Now I want to use a SUM function to calculate totalamount according to the memtype.

I tried something as follows :

select sum(totalamount) from loan,member where member.mem_type='Regular'
2
  • Memberid of member table is a foreign key in Loan Table Commented Apr 7, 2012 at 11:34
  • Please use ANSI 92 join style syntax. Commented Apr 7, 2012 at 11:45

1 Answer 1

1

Do you mean like this:

select sum(totalamount) AS Total 
from loan
JOIN member ON Memberid=loan.Memberid   
where member.mem_type='Regular'

Or if you want to select mem_type as well then something like this:

select sum(totalamount) AS Total,member.mem_type 
from loan
JOIN member ON Memberid=loan.Memberid   
where member.mem_type='Regular'
GROUP BY member.mem_type
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.