Hi,

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?

Thanks.

Recommended Answers

All 2 Replies

Hi,

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 developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.