How to calculate sum of two columns from two different tables without where clause?

后端 未结 1 1619
庸人自扰
庸人自扰 2021-01-07 10:06

I am using the following sql statement to sum values from two columns from two different tables. The statement can output but not the desired result.

SELECT
         


        
1条回答
  •  走了就别回头了
    2021-01-07 10:31

    This should do it:

    select income, expense, income-expense balance
    from (select sum(rate) income
          from _income) i
    JOIN (select sum(rate) expense
          from _expense) e
    

    0 讨论(0)
提交回复
热议问题