I have two tables. Payment and expense.

1. select sum(amount) from payment
gives me total payment amount

2. select sum(amount) from expense
gives me total expense.

3. I want to join payment and expense table. How can i subtract query1 minus query2 in one join query?


Recommended Answers

All 2 Replies


You can give a try like this;

select SUM(amount)+ (select SUM(amount) from expenses) from payments

But not sure about group by fields. let us know

Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.