like1824

求和:

select sum(A) from table1 where id = \'1\';

select sum(B) from table2 where id = \'1\';

 

若求和值为Null,需要转换,否组会报错

通过IFNULL转换,转换格式:IFNULL(字段,0)

调整后如下:

select IFNULL(sum(A),0)  from table1 where id = \'1\';

select IFNULL(sum(B),0)  from table2 where id = \'1\';

 

相减:

select (select IFNULL(sum(A),0)  from table1 where id = \'1\') - (select IFNULL(sum(B),0)  from table2 where id = \'1\')

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-02-11
  • 2021-06-03
  • 2021-10-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-07
  • 2022-12-23
  • 2021-06-25
  • 2021-07-26
  • 2021-09-09
相关资源
相似解决方案